|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
using DSWeb.Areas.OA.Models.WorkFlow;
|
|
|
using DSWeb.Common.DB;
|
|
|
using DSWeb.EntityDA;
|
|
|
using DSWeb.MvcShipping.DAL.MsInfoClient;
|
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
using DSWeb.MvcShipping.Models.MsCtExplan;
|
|
|
using DSWeb.MvcShipping.Models.MsInfoClient;
|
|
|
using DSWeb.SoftMng.BLL;
|
|
|
using DSWeb.SoftMng.Models.MsInfoClass;
|
|
|
using DSWeb.SoftMng.Models.MsInfoClientItem;
|
|
|
using DSWeb.TruckMng.Helper.Repository;
|
|
|
using HcUtility.Comm;
|
|
|
using HcUtility.Core;
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
using NPOI.SS.UserModel;
|
|
|
using NPOI.XSSF.UserModel;
|
|
|
using Spire.Pdf;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Data.SqlClient;//使用sqlcomm
|
|
|
using System.IO;//用于向数据库中存取图片
|
|
|
using System.Linq;
|
|
|
using System.Net;
|
|
|
using System.Text;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using System.Web;
|
|
|
using System.Web.Mvc;
|
|
|
using System.Security.Cryptography;
|
|
|
using System.Threading;
|
|
|
|
|
|
using DSWeb.Areas.Dispatch.Helper;
|
|
|
using DSWeb.MvcShipping.Models.MsOpBillYj;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
using javax.xml.crypto;
|
|
|
using NPOI.OpenXmlFormats.Dml;
|
|
|
using sun.security.jgss;
|
|
|
using Quartz.Util;
|
|
|
using DSWeb.MvcShipping.DAL.MsOpSeaeEdiPortDAL;
|
|
|
using DSWeb.MvcShipping.Models.MsOpSeae;
|
|
|
using DSWeb.MvcShipping.DAL.MsOpSeaeDAL;
|
|
|
using Aspose.Cells.Drawing;
|
|
|
using DSWeb.MvcShipping.Models.MsOp_BLISSUE;
|
|
|
using System.Data.Entity.Migrations;
|
|
|
using DSWeb.MvcContainer.Models.MsOpPrice;
|
|
|
using Microsoft.Owin;
|
|
|
using System.Drawing;
|
|
|
using System.Collections;
|
|
|
using DSWeb.MvcShipping.DAL.MsOpSeaeEdiDAL;
|
|
|
using System.Net.Mail;
|
|
|
using System.Net.Mime;
|
|
|
using DSWeb.MvcShipping.DAL.DsSendmail;
|
|
|
using DSWeb.MvcShipping.Models.MsOpMailLog;
|
|
|
using MimeKit.Text;
|
|
|
using CommonTool.MailKit;
|
|
|
using System.Web.UI.WebControls;
|
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
|
|
using DSWeb.SoftMng.Model;
|
|
|
using System.Configuration;
|
|
|
using ICSharpCode.SharpZipLib.BZip2;
|
|
|
|
|
|
namespace DSWeb.Areas.CommMng.DAL
|
|
|
{
|
|
|
public class BasicDataRefDAL
|
|
|
{
|
|
|
#region 费用代码
|
|
|
public static List<FeeTypeRefModel> GetFeeTypeRefList()
|
|
|
{
|
|
|
return GetFeeTypeRefList(String.Empty);
|
|
|
}
|
|
|
|
|
|
public static List<FeeTypeRefModel> GetFeeTypeRefList(string sCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("Select FeeCode,Name,CodeAndName ");
|
|
|
strSql.Append(" from vMsTruckFeeType ");
|
|
|
if (!string.IsNullOrEmpty(sCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + sCondition);
|
|
|
}
|
|
|
strSql.Append(" order by FeeCode");
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
var evList = new List<FeeTypeRefModel>();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
var evData = new FeeTypeRefModel();
|
|
|
evData.FeeCode = Convert.ToString(reader["FeeCode"]);
|
|
|
evData.Name = Convert.ToString(reader["Name"]);
|
|
|
evData.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
evList.Add(evData);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return evList;
|
|
|
}
|
|
|
|
|
|
public static List<FeeTypeRefModel> GetFeeGroupRefList()
|
|
|
{
|
|
|
return GetFeeGroupRefList(String.Empty);
|
|
|
}
|
|
|
|
|
|
public static List<FeeTypeRefModel> GetFeeGroupRefList(string sCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("Select feegroupcode FeeCode,feegroupname Name,feegroupcode+'_'+feegroupname CodeAndName ");
|
|
|
strSql.Append(" from code_fee_group ");
|
|
|
if (!string.IsNullOrEmpty(sCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + sCondition);
|
|
|
}
|
|
|
strSql.Append(" order by feegroupcode");
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
var evList = new List<FeeTypeRefModel>();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
var evData = new FeeTypeRefModel();
|
|
|
evData.FeeCode = Convert.ToString(reader["FeeCode"]);
|
|
|
evData.Name = Convert.ToString(reader["Name"]);
|
|
|
evData.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
evList.Add(evData);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return evList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 用户
|
|
|
|
|
|
|
|
|
|
|
|
static public List<UserRefModel> GetActionUserRefList(string strCondition, string modulename, string dbname = "")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("GID,UserCode,UserName,CodeAndName,CORPID,DEPTGID,DEPTNAME");
|
|
|
strSql.Append(" from vMsActionUser where MODULENAME='" + modulename + "' ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
return SetUserRefData(strSql, dbname);
|
|
|
}
|
|
|
|
|
|
static public List<UserRefModel> GetUserRefList()
|
|
|
{
|
|
|
return GetUserRefList(string.Empty);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// UserCode,UserName,CodeAndName,CORPID,DEPTGID,DEPTNAME
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition"></param>
|
|
|
/// <param name="dbname"></param>
|
|
|
/// <returns></returns>
|
|
|
static public List<UserRefModel> GetUserRefList(string strCondition, string dbname = "")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("GID,UserCode,UserName,CodeAndName,CORPID,DEPTGID,DEPTNAME");
|
|
|
strSql.Append(" from vMsTruckUser ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetUserRefData(strSql, dbname);
|
|
|
}
|
|
|
|
|
|
private static List<UserRefModel> SetUserRefData(StringBuilder strSql, string dbname = "")
|
|
|
{
|
|
|
var headList = new List<UserRefModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
if (dbname != "") db = DatabaseFactory.CreateDatabase(dbname);
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
UserRefModel data = new UserRefModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.UserCode = Convert.ToString(reader["UserCode"]);
|
|
|
data.UserName = Convert.ToString(reader["UserName"]);
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
data.CORPID = Convert.ToString(reader["CORPID"]);
|
|
|
data.DEPTGID = Convert.ToString(reader["DEPTGID"]);
|
|
|
data.DEPTNAME = Convert.ToString(reader["DEPTNAME"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
UserRefModel adata = new UserRefModel();
|
|
|
#region Set DB data to Object
|
|
|
adata.GID = "";
|
|
|
adata.UserCode = "";
|
|
|
adata.UserName = "";
|
|
|
adata.CodeAndName = "";
|
|
|
adata.CORPID = "";
|
|
|
adata.DEPTGID = "";
|
|
|
adata.DEPTNAME = "";
|
|
|
#endregion
|
|
|
headList.Add(adata);
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<UserLinkRefModel> GetUserLinkRefList(string strCondition, string COMPANYID, string CUSTOMERNAME = "")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("l.USERID GID,u.CODENAME UserCode,u.SHOWNAME UserName,u.CODENAME+'-'+u.SHOWNAME CodeAndName,");
|
|
|
strSql.Append("l.OFFICEPHONE Tel,l.FAX Fax,l.EMAIL1 Email,l.DEPTNAME,c.COMPANYID");
|
|
|
strSql.Append(" from [user] u left join user_baseinfo l on (u.gid=l.USERID) ");
|
|
|
strSql.Append(" left join user_company c on (u.gid=c.USERID) ");
|
|
|
var SeaeDefaultSort = MsSysParamSetDAL.GetData("PARAMNAME='OPONLYSUBCOMPANY'");
|
|
|
if (SeaeDefaultSort.PARAMVALUE != "" && SeaeDefaultSort.PARAMVALUE == "1")
|
|
|
strSql.Append(" where c.companyid='" + COMPANYID + "' ");
|
|
|
else
|
|
|
strSql.Append(" where 1=1 ");
|
|
|
if (!string.IsNullOrEmpty(CUSTOMERNAME)) {
|
|
|
var SALEONLYCUSTOMERNAME = MsSysParamSetDAL.GetData("PARAMNAME='SALEONLYCUSTOMERNAME'");
|
|
|
if (SALEONLYCUSTOMERNAME.PARAMVALUE == "1") {
|
|
|
strSql.Append(" AND u.SHOWNAME IN (" + GetCustSale(CUSTOMERNAME) + ") ");
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" order by u.CODENAME,u.SHOWNAME ");
|
|
|
|
|
|
return SetUserLinkRefData(strSql);
|
|
|
}
|
|
|
|
|
|
static public string GetCustSale(string customername)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "SELECT ''''+REPLACE(SALE,',',''',''')+'''' BLCOUNT FROM [info_client] WHERE SHORTNAME = '" + customername + "'");
|
|
|
if (string.IsNullOrEmpty(BLCOUNT)) BLCOUNT = "'1111'";
|
|
|
return BLCOUNT;
|
|
|
}
|
|
|
|
|
|
static public UserLinkRefModel GetUserLinkRef(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("l.USERID GID,u.USERNAME UserCode,u.SHOWNAME UserName,u.CODENAME+'-'+u.SHOWNAME CodeAndName,");
|
|
|
strSql.Append("l.OFFICEPHONE Tel,l.FAX Fax,l.EMAIL1 Email,l.DEPTNAME,c.COMPANYID");
|
|
|
strSql.Append(" from [user] u left join user_baseinfo l on (u.gid=l.USERID) ");
|
|
|
strSql.Append(" left join user_company c on (u.gid=c.USERID) ");
|
|
|
strSql.Append(" where 1=1 ");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" order by u.CODENAME,u.SHOWNAME ");
|
|
|
var list = SetUserLinkRefData(strSql);
|
|
|
if (list.Count > 0)
|
|
|
return list[0];
|
|
|
return new UserLinkRefModel();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
private static List<UserLinkRefModel> SetUserLinkRefData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<UserLinkRefModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
UserLinkRefModel data = new UserLinkRefModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.UserCode = Convert.ToString(reader["UserCode"]);
|
|
|
data.UserName = Convert.ToString(reader["UserName"]);
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
data.Tel = Convert.ToString(reader["Tel"]);
|
|
|
data.Fax = Convert.ToString(reader["Fax"]);
|
|
|
data.Email = Convert.ToString(reader["Email"]);
|
|
|
data.DEPTNAME = Convert.ToString(reader["DEPTNAME"]);
|
|
|
data.CORPID = Convert.ToString(reader["COMPANYID"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
UserLinkRefModel adata = new UserLinkRefModel();
|
|
|
#region Set DB data to Object
|
|
|
adata.GID = "";
|
|
|
adata.UserCode = "";
|
|
|
adata.UserName = "";
|
|
|
adata.CodeAndName = "";
|
|
|
adata.Tel = "";
|
|
|
adata.Fax = "";
|
|
|
adata.Email = "";
|
|
|
#endregion
|
|
|
headList.Add(adata);
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 配料
|
|
|
public static List<PluRefModel> GetPluRefList()
|
|
|
{
|
|
|
return GetPluRefList(String.Empty);
|
|
|
}
|
|
|
|
|
|
public static List<PluRefModel> GetPluRefList(string sCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("Select PluCode,PluName,PluCode+'-'+PluName as CodeAndName,Unit,Spec,Price ");
|
|
|
strSql.Append(" from tMsTruckPlu ");
|
|
|
if (!string.IsNullOrEmpty(sCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + sCondition);
|
|
|
}
|
|
|
strSql.Append(" order by PluCode");
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
var evList = new List<PluRefModel>();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
var evData = new PluRefModel();
|
|
|
evData.PluCode = Convert.ToString(reader["PluCode"]);
|
|
|
evData.PluName = Convert.ToString(reader["PluName"]);
|
|
|
evData.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
evData.Unit = Convert.ToString(reader["Unit"]);
|
|
|
evData.Spec = Convert.ToString(reader["Spec"]);
|
|
|
evData.Price = Convert.ToDecimal(reader["Price"]);
|
|
|
evList.Add(evData);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return evList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 客户参照,对应95004(vMsTruckClient)
|
|
|
static public List<CustomRefModel> GetCustomRefList(string lan)
|
|
|
{
|
|
|
return GetCustomRefList(string.Empty, "", "", "0", lan);
|
|
|
}
|
|
|
|
|
|
static public List<CustomRefModel> GetCustomRefList(string strCondition, string IsEnableCustRange = "0", string userid = "", string isall = "0", string lan = "")
|
|
|
{
|
|
|
var strSql = GetCustomRefList_GetSqlStr(strCondition, IsEnableCustRange, userid, isall, lan);
|
|
|
return SetCustomRefData(strSql);
|
|
|
}
|
|
|
|
|
|
public static StringBuilder GetCustomRefList_GetSqlStr(string strCondition, string IsEnableCustRange = "0", string userid = "", string isall = "0", string lan = "")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
if (lan == "en-us")
|
|
|
{
|
|
|
strSql.Append("Gid,CODENAME AS CustCode, ESHORTNAME AS CustName,CODENAME + '-' + ESHORTNAME AS CodeAndName,ESHORTNAME + '-' + EnFullName AS CodeAndFull,BillRises1");
|
|
|
strSql.Append(",UNITPRICE,description,EnFullName KFCodename,SALE,OP,DOC,CUSTSERVICE,FEEFRT,BSSOURCE,[EMAIL],[TEL],SALECORPID ");
|
|
|
strSql.Append(",(select top 1 CONTRACTNO from info_client_contract WHERE LINKID=info_Client.GID order by STARTDATE desc) CONTRACTNO ");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("Gid,CODENAME AS CustCode, SHORTNAME AS CustName,CODENAME + '-' + SHORTNAME AS CodeAndName,CODENAME + '-' + description AS CodeAndFull,BillRises1");
|
|
|
strSql.Append(",UNITPRICE,description,SHORTNAME+'_'+description KFCodename,SALE,OP,DOC,CUSTSERVICE,FEEFRT,BSSOURCE,[EMAIL],[TEL],SALECORPID ");
|
|
|
strSql.Append(",(select top 1 CONTRACTNO from info_client_contract WHERE LINKID=info_Client.GID order by STARTDATE desc) CONTRACTNO ");
|
|
|
}
|
|
|
|
|
|
strSql.Append(" from info_Client where 1=1 "); // BLSTATUS=0
|
|
|
|
|
|
if (isall != "1")
|
|
|
{
|
|
|
var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'");
|
|
|
if (InfoClintBlstatus.PARAMVALUE != "")
|
|
|
{
|
|
|
if (InfoClintBlstatus.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(" and BLSTATUS=0 ");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
if (IsEnableCustRange == "1")
|
|
|
strSql.Append(" and (SHORTNAME in (SELECT SHORTNAME from info_client_range where USERID='" + userid + "' ) or SHORTNAME not in (SELECT SHORTNAME from info_client_range )) ");
|
|
|
|
|
|
|
|
|
strSql.Append(" ORDER BY CODENAME ");
|
|
|
return strSql;
|
|
|
}
|
|
|
|
|
|
static public string GetHTStorageName()
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("Gid,CODENAME AS CustCode, SHORTNAME AS CustName,CODENAME + '-' + SHORTNAME AS CodeAndName,BillRises1");
|
|
|
strSql.Append(",UNITPRICE,description,SHORTNAME+'_'+description KFCodename,SALE,OP,DOC,CUSTSERVICE,FEEFRT,BSSOURCE,[EMAIL],[TEL],SALECORPID ");
|
|
|
strSql.Append(",'' CONTRACTNO ");
|
|
|
|
|
|
strSql.Append(" from info_Client where 1=1 AND ISWAREHOUSE = '1' "); // BLSTATUS=0
|
|
|
var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'");
|
|
|
if (InfoClintBlstatus.PARAMVALUE != "")
|
|
|
{
|
|
|
if (InfoClintBlstatus.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(" and BLSTATUS=0 ");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
strSql.Append(" ORDER BY CODENAME ");
|
|
|
|
|
|
return SetCustomRefData(strSql)[0].CustName.ToString();
|
|
|
}
|
|
|
|
|
|
private static List<CustomRefModel> SetCustomRefData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CustomRefModel>();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CustomRefModel data = new CustomRefModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GId = Convert.ToString(reader["GId"]);
|
|
|
data.CustCode = Convert.ToString(reader["CustCode"]);
|
|
|
data.CustName = Convert.ToString(reader["CustName"]);
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
|
|
|
data.BillRises1 = Convert.ToString(reader["BillRises1"]);
|
|
|
data.UNITPRICE = Convert.ToString(reader["UNITPRICE"]);
|
|
|
data.DESCRIPTION = Convert.ToString(reader["description"]);
|
|
|
data.KFCodename = Convert.ToString(reader["KFCodename"]);
|
|
|
data.SALE = Convert.ToString(reader["SALE"]);
|
|
|
data.FEEFRT = Convert.ToString(reader["FEEFRT"]);
|
|
|
data.BSSOURCE = Convert.ToString(reader["BSSOURCE"]);
|
|
|
data.EMAIL = Convert.ToString(reader["EMAIL"]);
|
|
|
data.TEL = Convert.ToString(reader["TEL"]);
|
|
|
data.SALECORPID = Convert.ToString(reader["SALECORPID"]);
|
|
|
data.OP = Convert.ToString(reader["OP"]);
|
|
|
data.DOC = Convert.ToString(reader["DOC"]);
|
|
|
data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]);
|
|
|
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
CustomRefModel adata = new CustomRefModel();
|
|
|
#region Set DB data to Object
|
|
|
adata.GId = "";
|
|
|
adata.CustCode = "";
|
|
|
adata.CustName = "";
|
|
|
adata.CodeAndName = "";
|
|
|
adata.BillRises1 = "";
|
|
|
adata.UNITPRICE = "";
|
|
|
adata.DESCRIPTION = "";
|
|
|
adata.KFCodename = "";
|
|
|
adata.SALE = "";
|
|
|
adata.FEEFRT = "";
|
|
|
adata.BSSOURCE = "";
|
|
|
#endregion
|
|
|
|
|
|
headList.Add(adata);
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<CustomYardRefModel> GetCustomYardRefList(string strCondition, string IsEnableCustRange = "0", string userid = "", string lan = "")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
if (lan == "en-us") {
|
|
|
strSql.Append("Gid,ESHORTNAME as CustCode,ESHORTNAME as CustName,ESHORTNAME as CodeAndName,ADDR");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
strSql.Append("Gid,CODENAME as CustCode,SHORTNAME as CustName,CODENAME+'-'+SHORTNAME as CodeAndName,ADDR");
|
|
|
strSql.Append(" from info_client where 1=1 ");
|
|
|
|
|
|
var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'");
|
|
|
if (InfoClintBlstatus.PARAMVALUE != "")
|
|
|
{
|
|
|
if (InfoClintBlstatus.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(" and BLSTATUS=0 ");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
//if (IsEnableCustRange == "1")
|
|
|
// strSql.Append(" and SHORTNAME in (SELECT SHORTNAME from info_client_range where USERID='" + userid + "' ) ");
|
|
|
|
|
|
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
return SetCustomYardRefData(strSql);
|
|
|
}
|
|
|
|
|
|
public static string GetCustomerCode(string customername)
|
|
|
{
|
|
|
var condition = " SHORTNAME='" + customername + "' ";
|
|
|
|
|
|
var _list = GetCustomYardRefList(condition);
|
|
|
|
|
|
if (_list != null && _list.Count > 0)
|
|
|
{
|
|
|
return _list[0].CustCode;
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
private static List<CustomYardRefModel> SetCustomYardRefData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CustomYardRefModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CustomYardRefModel data = new CustomYardRefModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GId = Convert.ToString(reader["GId"]);
|
|
|
data.CustCode = Convert.ToString(reader["CustCode"]);
|
|
|
data.CustName = Convert.ToString(reader["CustName"]);
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
data.ADDR = Convert.ToString(reader["ADDR"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
CustomYardRefModel adata = new CustomYardRefModel();
|
|
|
#region Set DB data to Object
|
|
|
adata.GId = "";
|
|
|
adata.CustCode = "";
|
|
|
adata.CustName = "";
|
|
|
adata.CodeAndName = "";
|
|
|
#endregion
|
|
|
headList.Add(adata);
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<CustomInvRefModel> GetCustomInvRefList(string strCondition, string IsEnableCustRange = "0", string userid = "", string lan = "")
|
|
|
{
|
|
|
var strSql = GetCustomInvRefList_SqlStr(strCondition, IsEnableCustRange, userid, lan);
|
|
|
return SetCustomInvRefData(strSql, false, lan);
|
|
|
}
|
|
|
|
|
|
static public List<CustomInvRefModel> GetCustomInvRef(string strCondition, string IsEnableCustRange = "0", string userid = "", string lan = "")
|
|
|
{
|
|
|
var strSql = GetCustomInvRefList_SqlStr(strCondition, IsEnableCustRange, userid, lan);
|
|
|
return SetCustomInvRefData(strSql, false, lan);
|
|
|
}
|
|
|
|
|
|
public static StringBuilder GetCustomInvRefList_SqlStr(string strCondition, string IsEnableCustRange = "0", string userid = "", string lan = "")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
if (lan == "en-us") {
|
|
|
strSql.Append("Gid,ESHORTNAME as CustCode,ESHORTNAME as CustName,ESHORTNAME as CodeAndName,BillRises1,INVADDRTEL,[DESCRIPTION]");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
strSql.Append("Gid,CODENAME as CustCode,SHORTNAME as CustName,CODENAME+'-'+SHORTNAME as CodeAndName,BillRises1,INVADDRTEL,[DESCRIPTION]");
|
|
|
strSql.Append(",RmbBillRises,(select top 1 BANKNAME+' '+ACCOUNT FROM info_client_bank WHERE CURRENCY='RMB' AND LINKID=info_client.GID) Rmbbank,Rmbaccount,usdBillRises,(select top 1 BANKNAME+' '+ACCOUNT FROM info_client_bank WHERE CURRENCY='USD' AND LINKID=info_client.GID) usdbank,usdaccount,TaxNo,Addr,Tel,EMAIL");
|
|
|
strSql.Append(" from info_client where 1=1 ");
|
|
|
|
|
|
var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'");
|
|
|
if (InfoClintBlstatus.PARAMVALUE != "")
|
|
|
{
|
|
|
if (InfoClintBlstatus.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(" and BLSTATUS=0 ");
|
|
|
}
|
|
|
}
|
|
|
if (IsEnableCustRange == "1")
|
|
|
strSql.Append(" and (SHORTNAME in (SELECT SHORTNAME from info_client_range where USERID='" + userid + "' ) or SHORTNAME not in (SELECT SHORTNAME from info_client_range )) ");
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and (" + strCondition + ")");
|
|
|
}
|
|
|
return strSql;
|
|
|
}
|
|
|
|
|
|
private static List<CustomInvRefModel> SetCustomInvRefData(StringBuilder strSql, bool islist = true, string lan = "")
|
|
|
{
|
|
|
var headList = new List<CustomInvRefModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
if (islist)
|
|
|
headList.Add(new CustomInvRefModel());
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CustomInvRefModel data = new CustomInvRefModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GId = Convert.ToString(reader["GId"]);
|
|
|
data.CustCode = Convert.ToString(reader["CustCode"]);
|
|
|
data.CustName = Convert.ToString(reader["CustName"]);
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);
|
|
|
data.BillRises1 = Convert.ToString(reader["BillRises1"]);
|
|
|
data.RMBBillRises = Convert.ToString(reader["RmbBillRises"]);
|
|
|
data.RMBBank = Convert.ToString(reader["Rmbbank"]);
|
|
|
data.RMBAccount = Convert.ToString(reader["Rmbaccount"]);
|
|
|
data.USDBillRises = Convert.ToString(reader["usdBillRises"]);
|
|
|
data.USDBank = Convert.ToString(reader["usdbank"]);
|
|
|
data.USDAccount = Convert.ToString(reader["usdaccount"]);
|
|
|
data.TaxNo = Convert.ToString(reader["TaxNo"]);
|
|
|
data.Addr = Convert.ToString(reader["Addr"]);
|
|
|
data.Tel = Convert.ToString(reader["Tel"]);
|
|
|
data.INVADDRTEL = Convert.ToString(reader["INVADDRTEL"]);
|
|
|
if (data.BillRises1 == "")
|
|
|
data.BillRises1 = Convert.ToString(reader["DESCRIPTION"]);
|
|
|
|
|
|
if (data.RMBBillRises == "")
|
|
|
data.RMBBillRises = Convert.ToString(reader["DESCRIPTION"]);
|
|
|
|
|
|
|
|
|
if (data.USDBillRises == "")
|
|
|
data.USDBillRises = Convert.ToString(reader["DESCRIPTION"]);
|
|
|
data.EMail = Convert.ToString(reader["EMAIL"]);
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
|
|
|
static public List<CustomContactRefModel> GetCustomContactRefList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("LinkId,CODENAME,SHOWNAME,Tel,EMAIL");
|
|
|
strSql.Append(" from info_client_contact ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetCustomContactRefData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<CustomContactRefModel> SetCustomContactRefData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CustomContactRefModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CustomContactRefModel data = new CustomContactRefModel();
|
|
|
#region Set DB data to Object
|
|
|
data.LinkId = Convert.ToString(reader["LinkId"]);
|
|
|
data.Code = Convert.ToString(reader["CODENAME"]);
|
|
|
data.Name = Convert.ToString(reader["SHOWNAME"]);
|
|
|
data.Tel = Convert.ToString(reader["Tel"]);
|
|
|
data.EMail = Convert.ToString(reader["EMAIL"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<CustomRefModel> GetAirLinesList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("Gid,CODENAME AS CustCode, SHORTNAME AS CustName,CODENAME + '-' + SHORTNAME AS CodeAndName,BillRises1");
|
|
|
strSql.Append(",UNITPRICE,description,SHORTNAME+'_'+description KFCodename,SALE,ISAGENTCN ");
|
|
|
strSql.Append(" from info_Client where 1=1 "); // BLSTATUS=0
|
|
|
var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'");
|
|
|
if (InfoClintBlstatus.PARAMVALUE != "")
|
|
|
{
|
|
|
if (InfoClintBlstatus.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(" and BLSTATUS=0 ");
|
|
|
}
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" ORDER BY CODENAME ");
|
|
|
|
|
|
return SetAirLinesData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<CustomRefModel> SetAirLinesData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CustomRefModel>();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CustomRefModel data = new CustomRefModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GId = Convert.ToString(reader["GId"]);
|
|
|
data.CustCode = Convert.ToString(reader["CustCode"]);
|
|
|
data.CustName = Convert.ToString(reader["CustName"]);
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
data.BillRises1 = Convert.ToString(reader["BillRises1"]);
|
|
|
data.UNITPRICE = Convert.ToString(reader["UNITPRICE"]);
|
|
|
data.DESCRIPTION = Convert.ToString(reader["description"]);
|
|
|
data.KFCodename = Convert.ToString(reader["KFCodename"]);
|
|
|
data.SALE = Convert.ToString(reader["SALE"]);
|
|
|
data.ISAGENTCN = Convert.ToString(reader["ISAGENTCN"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
CustomRefModel adata = new CustomRefModel();
|
|
|
#region Set DB data to Object
|
|
|
adata.GId = "";
|
|
|
adata.CustCode = "";
|
|
|
adata.CustName = "";
|
|
|
adata.CodeAndName = "";
|
|
|
adata.BillRises1 = "";
|
|
|
adata.UNITPRICE = "";
|
|
|
adata.DESCRIPTION = "";
|
|
|
adata.KFCodename = "";
|
|
|
adata.SALE = "";
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(adata);
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 客户参照,对应95004.内贸空运 获取vip价格
|
|
|
static public List<CustomVIPModel> GetCustom_SPPrice()
|
|
|
{
|
|
|
return GetCustom_SPPrice(string.Empty);
|
|
|
}
|
|
|
|
|
|
static public List<CustomVIPModel> GetCustom_SPPrice(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" SELECT Gid,CODENAME AS CustCode, SHORTNAME AS CustName,CODENAME + '-' + SHORTNAME AS CodeAndName,BillRises1 ");
|
|
|
strSql.Append(" ,UNITPRICE,description,SHORTNAME+'_'+description KFCodename,SALE ");
|
|
|
strSql.Append(" ,(case when (select dbo.Get_ClientFee(SHORTNAME,'VIP单价'))>0 ");
|
|
|
strSql.Append(" or (select dbo.Get_ClientFee(SHORTNAME,'VIP单票'))>0 then 1 else 0 end )ISVIP ");
|
|
|
strSql.Append(" ,(select dbo.Get_ClientFee(SHORTNAME,'VIP单价')) VIPDJ ");
|
|
|
strSql.Append(" ,(select dbo.Get_ClientFee(SHORTNAME,'VIP单票')) VIPDP ");
|
|
|
strSql.Append(" from info_Client where 1=1 ");
|
|
|
var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'");
|
|
|
if (InfoClintBlstatus.PARAMVALUE != "")
|
|
|
{
|
|
|
if (InfoClintBlstatus.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(" and BLSTATUS=0 ");
|
|
|
}
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" ORDER BY CODENAME ");
|
|
|
|
|
|
return SetCustom_SPPrice(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<CustomVIPModel> SetCustom_SPPrice(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CustomVIPModel>();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CustomVIPModel data = new CustomVIPModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GId = Convert.ToString(reader["GId"]);
|
|
|
data.CustCode = Convert.ToString(reader["CustCode"]);
|
|
|
data.CustName = Convert.ToString(reader["CustName"]);
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
data.BillRises1 = Convert.ToString(reader["BillRises1"]);
|
|
|
data.UNITPRICE = Convert.ToString(reader["UNITPRICE"]);
|
|
|
data.DESCRIPTION = Convert.ToString(reader["description"]);
|
|
|
data.KFCodename = Convert.ToString(reader["KFCodename"]);
|
|
|
data.SALE = Convert.ToString(reader["SALE"]);
|
|
|
data.ISVIP = Convert.ToString(reader["ISVIP"]);
|
|
|
data.VIPDJ = Convert.ToString(reader["VIPDJ"]);
|
|
|
data.VIPDP = Convert.ToString(reader["VIPDP"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
CustomVIPModel adata = new CustomVIPModel();
|
|
|
#region Set DB data to Object
|
|
|
adata.GId = "";
|
|
|
adata.CustCode = "";
|
|
|
adata.CustName = "";
|
|
|
adata.CodeAndName = "";
|
|
|
adata.BillRises1 = "";
|
|
|
adata.UNITPRICE = "";
|
|
|
adata.DESCRIPTION = "";
|
|
|
adata.KFCodename = "";
|
|
|
adata.SALE = "";
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(adata);
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 客户银行账户列表
|
|
|
static public List<MsClientAccount> GetMsClientAccount(string condition)
|
|
|
{
|
|
|
return GetMsClientAccountData(condition);
|
|
|
}
|
|
|
|
|
|
static public List<MsClientAccount> GetMsClientAccountData(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("GID,BANKNAME,ACCOUNT,BANKNAME+'-'+ACCOUNT BANKNAME_ACCOUNT");
|
|
|
strSql.Append(" from info_client_bank ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetMsClientAccountData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<MsClientAccount> SetMsClientAccountData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsClientAccount>();
|
|
|
MsClientAccount adata = new MsClientAccount();
|
|
|
#region Set DB data to Object
|
|
|
adata.GID = "";
|
|
|
adata.BANKNAME = "";
|
|
|
adata.ACCOUNT = "";
|
|
|
adata.BANKNAME_ACCOUNT = "";
|
|
|
#endregion
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsClientAccount data = new MsClientAccount();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.BANKNAME = Convert.ToString(reader["BANKNAME"]);
|
|
|
data.ACCOUNT = Convert.ToString(reader["ACCOUNT"]);
|
|
|
data.BANKNAME_ACCOUNT = Convert.ToString(reader["BANKNAME_ACCOUNT"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
headList.Add(adata);
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 业务来源
|
|
|
static public List<SourceModel> GetSourceList(string strCondition, string lan)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
if (lan == "en-us") {
|
|
|
strSql.Append("SOURCEID,ENAME SOURCENAME,CORPID,SOURCECODE,ENAME");
|
|
|
}
|
|
|
else
|
|
|
strSql.Append("SOURCEID,SOURCENAME,CORPID,SOURCECODE,ENAME");
|
|
|
strSql.Append(" from code_source ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetSourceData(strSql);
|
|
|
}
|
|
|
|
|
|
static public SourceModel GetSourceData(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("SOURCEID,SOURCENAME,CORPID,SOURCECODE,ENAME");
|
|
|
strSql.Append(" from code_source ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
var list = SetSourceData(strSql, true);
|
|
|
if (list.Count > 0)
|
|
|
return list[0];
|
|
|
return new SourceModel();
|
|
|
|
|
|
}
|
|
|
|
|
|
private static List<SourceModel> SetSourceData(StringBuilder strSql, bool isdata = false)
|
|
|
{
|
|
|
var headList = new List<SourceModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
SourceModel data = new SourceModel();
|
|
|
#region Set DB data to Object
|
|
|
data.SourceID = Convert.ToString(reader["SOURCEID"]);
|
|
|
data.SourceName = Convert.ToString(reader["SOURCENAME"]);
|
|
|
data.CorpID = Convert.ToString(reader["CORPID"]);
|
|
|
data.SOURCECODE = Convert.ToString(reader["SOURCECODE"]);
|
|
|
data.ENAME = Convert.ToString(reader["ENAME"]);
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
if (!isdata)
|
|
|
{
|
|
|
SourceModel adata = new SourceModel();
|
|
|
#region Set DB data to Object
|
|
|
adata.SourceID = "";
|
|
|
adata.SourceName = "";
|
|
|
adata.ENAME = "";
|
|
|
adata.CorpID = "";
|
|
|
#endregion
|
|
|
headList.Add(adata);
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<SourceDetailModel> GetSourceDetailList(string strCondition, string lan)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
if (lan == "en-us") {
|
|
|
strSql.Append("SOURCEDETAILID,SOURCEID,ENAME SOURCEDETAIL,ENAME");
|
|
|
}
|
|
|
else
|
|
|
strSql.Append("SOURCEDETAILID,SOURCEID,SOURCEDETAIL,ENAME");
|
|
|
strSql.Append(" from code_source_detail ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetSourceDetailData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<SourceDetailModel> SetSourceDetailData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<SourceDetailModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
SourceDetailModel data = new SourceDetailModel();
|
|
|
#region Set DB data to Object
|
|
|
data.SourceDetailID = Convert.ToString(reader["SOURCEDETAILID"]);
|
|
|
data.SourceID = Convert.ToString(reader["SOURCEID"]);
|
|
|
data.SourceDetail = Convert.ToString(reader["SOURCEDETAIL"]);
|
|
|
data.ENAME = Convert.ToString(reader["ENAME"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
SourceDetailModel adata = new SourceDetailModel();
|
|
|
#region Set DB data to Object
|
|
|
adata.SourceDetailID = "";
|
|
|
adata.SourceID = "";
|
|
|
adata.SourceDetail = "";
|
|
|
adata.ENAME = "";
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(adata);
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 部门
|
|
|
static public List<DeptModel> GetDeptList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("GID,LINKID,DEPTNO,DEPTNAME,MANAGE1,DEPTNO + '-' + DEPTNAME AS NOANDNAME");
|
|
|
strSql.Append(" from sys_dept ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetDeptData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<DeptModel> SetDeptData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<DeptModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
DeptModel data = new DeptModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.Deptno = Convert.ToString(reader["DEPTNO"]);
|
|
|
data.DeptName = Convert.ToString(reader["DEPTNAME"]);
|
|
|
data.Manage1 = Convert.ToString(reader["MANAGE1"]);
|
|
|
data.NOANDNAME = Convert.ToString(reader["NOANDNAME"]);
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 船名航次参照,对应95003(vMsTruckVoyInfo)
|
|
|
|
|
|
static public List<VoyRefModel> GetVoyRefList()
|
|
|
{
|
|
|
return GetVoyRefList(string.Empty);
|
|
|
}
|
|
|
|
|
|
static public List<VoyRefModel> GetVoyRefList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("VoyCode,VoyName,CodeAndName");
|
|
|
strSql.Append(" from vMsTruckVoyInfo ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetVoyRefData(strSql);
|
|
|
}
|
|
|
|
|
|
|
|
|
private static List<VoyRefModel> SetVoyRefData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<VoyRefModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
VoyRefModel data = new VoyRefModel();
|
|
|
#region Set DB data to Object
|
|
|
data.VoyCode = Convert.ToString(reader["VoyCode"]);
|
|
|
data.VoyName = Convert.ToString(reader["VoyName"]);
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 船名
|
|
|
|
|
|
|
|
|
static public List<VesselModel> GetVesselList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append(" VSID,VESSEL,CNAME,CARRIER,SHIPAGENCY,EDICODE,VESSEL+' '+CNAME CodeAndName");
|
|
|
strSql.Append(" from code_vessel ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetVesselData(strSql);
|
|
|
}
|
|
|
|
|
|
|
|
|
private static List<VesselModel> SetVesselData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<VesselModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
VesselModel data = new VesselModel();
|
|
|
#region Set DB data to Object
|
|
|
data.VSID = Convert.ToString(reader["VSID"]);
|
|
|
data.VESSEL = Convert.ToString(reader["VESSEL"]);
|
|
|
data.CNAME = Convert.ToString(reader["CNAME"]);
|
|
|
data.EDICODE = Convert.ToString(reader["EDICODE"]);
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
data.SHIPAGENCY = Convert.ToString(reader["SHIPAGENCY"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<VoyNoModel> GetVoyNoList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append(" VOID,VSID,VOYNO,PORTLOAD,PORTDISCHARGE,ETD,CLOSINGDATE,ETA,CORPID,YARDID,ENTREPORT,VESSEL,ATD,CLOSEDOCDATE ");
|
|
|
strSql.Append(" from code_voyno ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetVoyNoData(strSql);
|
|
|
}
|
|
|
|
|
|
|
|
|
private static List<VoyNoModel> SetVoyNoData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<VoyNoModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
VoyNoModel data = new VoyNoModel();
|
|
|
#region Set DB data to Object
|
|
|
data.VSID = Convert.ToString(reader["VSID"]);
|
|
|
data.VOYNO = Convert.ToString(reader["VOYNO"]);
|
|
|
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
|
|
|
data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]);
|
|
|
if (reader["ETD"] != DBNull.Value)
|
|
|
data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");
|
|
|
if (reader["CLOSINGDATE"] != DBNull.Value)
|
|
|
data.CLOSINGDATE = Convert.ToDateTime(reader["CLOSINGDATE"]).ToString("yyyy-MM-dd HH:mm");
|
|
|
if (reader["ETA"] != DBNull.Value)
|
|
|
data.ETA = Convert.ToDateTime(reader["ETA"]).ToString("yyyy-MM-dd");
|
|
|
if (reader["ATD"] != DBNull.Value)
|
|
|
data.ATD = Convert.ToDateTime(reader["ATD"]).ToString("yyyy-MM-dd");
|
|
|
|
|
|
if (reader["CLOSEDOCDATE"] != DBNull.Value)
|
|
|
data.CLOSEDOCDATE = Convert.ToDateTime(reader["CLOSEDOCDATE"]).ToString("yyyy-MM-dd HH:mm");
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 箱型表参照,对应95005(vMsTruckCtn)
|
|
|
|
|
|
static public List<CtnRefModel> GetCtnRefList()
|
|
|
{
|
|
|
return GetCtnRefList(string.Empty);
|
|
|
}
|
|
|
|
|
|
static public List<CtnRefModel> GetCtnRefList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append("CtnCode,CtnName,CodeAndName");
|
|
|
strSql.Append(" from vMsTruckCtn ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetCtnRefData(strSql);
|
|
|
}
|
|
|
|
|
|
|
|
|
private static List<CtnRefModel> SetCtnRefData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CtnRefModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CtnRefModel data = new CtnRefModel();
|
|
|
#region Set DB data to Object
|
|
|
data.CtnCode = Convert.ToString(reader["CtnCode"]);
|
|
|
data.CtnName = Convert.ToString(reader["CtnName"]);
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
CtnRefModel adata = new CtnRefModel();
|
|
|
#region Set DB data to Object
|
|
|
adata.CtnCode = "";
|
|
|
adata.CtnName = "";
|
|
|
adata.CodeAndName = "";
|
|
|
#endregion
|
|
|
headList.Add(adata);
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<CtnRefModel> GetCtnDispList()
|
|
|
{
|
|
|
return GetCtnDispList(string.Empty);
|
|
|
}
|
|
|
|
|
|
static public List<CtnRefModel> GetCtnDispList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select CtnCode,CtnName,CodeAndName,sort from [vMsImportCtnDisp]");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" order by sort ");
|
|
|
return SetCtnRefData(strSql);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 国家参照,(Import_country)
|
|
|
|
|
|
static public List<CountryModel> GetCountryRefList()
|
|
|
{
|
|
|
return GetCountryRefList(string.Empty);
|
|
|
}
|
|
|
|
|
|
static public List<CountryModel> GetCountryRefList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
// SELECT id,country_code,country,(country_code+'_'+country) as country_codeandname
|
|
|
//from import_country
|
|
|
strSql.Append("SELECT countryid,country,(countryid+'_'+country) as country_idandname");
|
|
|
strSql.Append(" from code_country ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetcountryRefData(strSql);
|
|
|
}
|
|
|
|
|
|
|
|
|
private static List<CountryModel> SetcountryRefData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CountryModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CountryModel data = new CountryModel();
|
|
|
#region Set DB data to Object
|
|
|
// data.id = Convert.ToString(reader["id"]);
|
|
|
data.countryid = Convert.ToString(reader["countryid"]);
|
|
|
data.country = Convert.ToString(reader["country"]);
|
|
|
data.country_idandname = Convert.ToString(reader["country_idandname"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 商品名称参照,(Import_Cargoinfo)
|
|
|
|
|
|
static public List<CargoModel> GetCargoRefList()
|
|
|
{
|
|
|
return GetCargoRefList(string.Empty);
|
|
|
}
|
|
|
|
|
|
static public List<CargoModel> GetCargoRefList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" select *,code+'_'+name codeandname from import_cargoinfo ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" order by code ");
|
|
|
return SetCargoRefData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<CargoModel> SetCargoRefData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CargoModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CargoModel data = new CargoModel();
|
|
|
#region Set DB data to Object
|
|
|
data.id = Convert.ToString(reader["id"]);
|
|
|
data.code = Convert.ToString(reader["code"]);
|
|
|
data.name = Convert.ToString(reader["name"]);
|
|
|
data.codeandname = Convert.ToString(reader["codeandname"]);
|
|
|
// data.tariff = Convert.ToString(reader["tariff"]);
|
|
|
// data.tax = Convert.ToString(reader["tax"]);
|
|
|
// data.tax_zz = Convert.ToString(reader["tax_zz"]);
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 商品名称参照 含tax,(Import_Cargoinfo)
|
|
|
|
|
|
static public List<CargoModel> GetCargoTax()
|
|
|
{
|
|
|
return GetCargoTax(string.Empty);
|
|
|
}
|
|
|
|
|
|
static public List<CargoModel> GetCargoTax(string strCondition)
|
|
|
{
|
|
|
//tariff 关税等级: 0最惠国 1普通 2零关税
|
|
|
var strSql = GetCargoTax_Sqlstr(strCondition);
|
|
|
return SetCargoTax(strSql);
|
|
|
}
|
|
|
|
|
|
public static StringBuilder GetCargoTax_Sqlstr(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" select ci.id,name,code+'_'+name codeandname,code, ");
|
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 ");
|
|
|
strSql.Append("and EnumTypeID=9000 and EnumValueID=cc.tariff) as tariff, ");
|
|
|
strSql.Append("case cc.tariff when 0 then ci.tax_zhg/100 when 1 then ci.tax_pt/100 when 2 then 0 end tax, ");
|
|
|
strSql.Append("ci.tax_zz/100 as tax_zz,ci.tax_cl as tax_cl from code_country cc,import_cargoinfo ci ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return strSql;
|
|
|
}
|
|
|
|
|
|
private static List<CargoModel> SetCargoTax(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CargoModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CargoModel data = new CargoModel();
|
|
|
#region Set DB data to Object
|
|
|
data.id = Convert.ToString(reader["id"]);
|
|
|
data.code = Convert.ToString(reader["code"]);
|
|
|
data.name = Convert.ToString(reader["name"]);
|
|
|
data.codeandname = Convert.ToString(reader["codeandname"]);
|
|
|
data.tariff = Convert.ToString(reader["tariff"]);
|
|
|
data.tax = Convert.ToString(reader["tax"]);
|
|
|
data.tax_zz = Convert.ToString(reader["tax_zz"]);
|
|
|
data.tax_cl = Convert.ToString(reader["tax_cl"]);
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 商品ciq名称参照,(Import_Cargociq)
|
|
|
|
|
|
static public List<CargociqModel> GetCargociqRefList(string strCondition = "")
|
|
|
{
|
|
|
if (strCondition.Trim().Length > 0)
|
|
|
if (strCondition.Trim().Substring(strCondition.Trim().Length - 1, 1) == "=")
|
|
|
{
|
|
|
return new List<CargociqModel>();
|
|
|
}
|
|
|
var strSql = GetCargociqRefList_Sqlstr(strCondition);
|
|
|
return SetCargociqRefData(strSql);
|
|
|
}
|
|
|
|
|
|
public static StringBuilder GetCargociqRefList_Sqlstr(string strCondition = "")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT *,ciqcode+'_'+ciqname as codeandname");
|
|
|
strSql.Append(" from import_cargociq ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" order by ciqcode ");
|
|
|
return strSql;
|
|
|
}
|
|
|
|
|
|
private static List<CargociqModel> SetCargociqRefData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CargociqModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CargociqModel data = new CargociqModel();
|
|
|
#region Set DB data to Object
|
|
|
data.id = Convert.ToString(reader["id"]);
|
|
|
data.ciqcode = Convert.ToString(reader["ciqcode"]);
|
|
|
data.ciqname = Convert.ToString(reader["ciqname"]);
|
|
|
data.codeandname = Convert.ToString(reader["codeandname"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 公司名称,(company)
|
|
|
|
|
|
static public List<companyModel> GetcompanyList()
|
|
|
{
|
|
|
return GetcompanyList(string.Empty);
|
|
|
}
|
|
|
|
|
|
static public List<companyModel> GetcompanyList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT *");
|
|
|
strSql.Append(" from company where isdeleted=0 ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
return SetcompanyData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<companyModel> SetcompanyData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<companyModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
companyModel data = new companyModel();
|
|
|
#region Set DB data to Object
|
|
|
data.gid = Convert.ToString(reader["gid"]);
|
|
|
data.code = Convert.ToString(reader["codename"]);
|
|
|
data.name = Convert.ToString(reader["name"]);
|
|
|
data.isdisable = Convert.ToString(reader["isdisable"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 币别,(currid)
|
|
|
|
|
|
static public List<currModel> GetcurrRefList()
|
|
|
{
|
|
|
return GetcurrRefList(string.Empty);
|
|
|
}
|
|
|
|
|
|
static public List<currModel> GetcurrRefList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select gid,codename,defaultrate from code_currency ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetcurrData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<currModel> SetcurrData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<currModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
currModel data = new currModel();
|
|
|
#region Set DB data to Object
|
|
|
data.gid = Convert.ToString(reader["gid"]);
|
|
|
data.codename = Convert.ToString(reader["codename"]);
|
|
|
data.defaultrate = Convert.ToString(reader["defaultrate"]);
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 进口贸易提醒,(import_remind)
|
|
|
|
|
|
static public List<RemindModel> GetRemindList()
|
|
|
{
|
|
|
return GetRemindList(string.Empty);
|
|
|
}
|
|
|
|
|
|
static public List<RemindModel> GetRemindList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select id,Remindname,Remindsql from Import_remind ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetRemindData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<RemindModel> SetRemindData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<RemindModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
RemindModel data = new RemindModel();
|
|
|
#region Set DB data to Object
|
|
|
data.RemindName = Convert.ToString(reader["Remindname"]);
|
|
|
data.RemindSql = Convert.ToString(reader["Remindsql"]);
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 贸易商/购货方combox,(seller buyer info_client)
|
|
|
|
|
|
static public List<TraderModel> GetTrader()
|
|
|
{
|
|
|
return GetTrader(string.Empty);
|
|
|
}
|
|
|
|
|
|
static public List<TraderModel> GetTrader(string strCondition)
|
|
|
{
|
|
|
var strSql = GetTrader_Getsqlstr(strCondition);
|
|
|
return SetTrader(strSql);
|
|
|
}
|
|
|
|
|
|
public static StringBuilder GetTrader_Getsqlstr(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" select gid,shortname as name,codename code,codename+'_'+shortname codename,description,EnFullName ");
|
|
|
strSql.Append(" ,codename+'_'+EnFullName codeEnname,ISSTOP,RCVMode from info_client where 1=1 ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'");
|
|
|
if (InfoClintBlstatus.PARAMVALUE != "")
|
|
|
{
|
|
|
if (InfoClintBlstatus.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(" and BLSTATUS=0 ");
|
|
|
}
|
|
|
}
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" order by codename ");
|
|
|
return strSql;
|
|
|
}
|
|
|
|
|
|
private static List<TraderModel> SetTrader(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<TraderModel>();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
TraderModel data = new TraderModel();
|
|
|
#region Set DB data to Object
|
|
|
data.gid = Convert.ToString(reader["gid"]);
|
|
|
data.name = Convert.ToString(reader["name"]);
|
|
|
data.code = Convert.ToString(reader["code"]);
|
|
|
data.codename = Convert.ToString(reader["codename"]);
|
|
|
data.description = Convert.ToString(reader["description"]);
|
|
|
data.EnFullName = Convert.ToString(reader["EnFullName"]);
|
|
|
data.codeEnName = Convert.ToString(reader["codeEnName"]);
|
|
|
data.ISSTOP = Convert.ToString(reader["ISSTOP"]);
|
|
|
data.RCVMode = Convert.ToString(reader["RCVMode"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
//
|
|
|
TraderModel data1 = new TraderModel();
|
|
|
#region Set DB data to Object
|
|
|
data1.gid = "";
|
|
|
data1.name = "";
|
|
|
data1.codename = "";
|
|
|
data1.description = "";
|
|
|
#endregion
|
|
|
headList.Add(data1);
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<TraderModel> GetPCTrader(string strCondition)
|
|
|
{
|
|
|
var strSql = GetPCTrader_Getsqlstr(strCondition);
|
|
|
return SetPCTrader(strSql);
|
|
|
}
|
|
|
|
|
|
public static StringBuilder GetPCTrader_Getsqlstr(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select gid,shortname as name,codename+'_'+shortname codename,description,EnFullName,codename+'_'+EnFullName codeEnname,ADDR from info_client where 1=1 ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'");
|
|
|
if (InfoClintBlstatus.PARAMVALUE != "")
|
|
|
{
|
|
|
if (InfoClintBlstatus.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(" and BLSTATUS=0 ");
|
|
|
}
|
|
|
}
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" order by codename ");
|
|
|
return strSql;
|
|
|
}
|
|
|
|
|
|
private static List<TraderModel> SetPCTrader(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<TraderModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
TraderModel data = new TraderModel();
|
|
|
#region Set DB data to Object
|
|
|
data.gid = Convert.ToString(reader["gid"]);
|
|
|
data.name = Convert.ToString(reader["name"]);
|
|
|
data.codename = Convert.ToString(reader["codename"]);
|
|
|
data.description = Convert.ToString(reader["description"]);
|
|
|
data.EnFullName = Convert.ToString(reader["EnFullName"]);
|
|
|
data.codeEnName = Convert.ToString(reader["codeEnName"]);
|
|
|
data.ADDR = Convert.ToString(reader["ADDR"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
//
|
|
|
TraderModel data1 = new TraderModel();
|
|
|
#region Set DB data to Object
|
|
|
data1.gid = "";
|
|
|
data1.name = "";
|
|
|
data1.codename = "";
|
|
|
data1.description = "";
|
|
|
#endregion
|
|
|
headList.Add(data1);
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获取银行名字列表
|
|
|
|
|
|
static public List<BankModel> GetBank()
|
|
|
{
|
|
|
return GetBank(string.Empty);
|
|
|
}
|
|
|
|
|
|
static public List<BankModel> GetBank(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select gid, bankname,FINANCESOFTCODE,FINANCESOFTCODE+'_'+bankname codename from sys_bank ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
return SetBank(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<BankModel> SetBank(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<BankModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
BankModel data = new BankModel();
|
|
|
#region Set DB data to Object
|
|
|
data.gid = Convert.ToString(reader["gid"]);
|
|
|
data.bankname = Convert.ToString(reader["bankname"]);
|
|
|
data.codename = Convert.ToString(reader["codename"]);
|
|
|
data.FINANCESOFTCODE = Convert.ToString(reader["FINANCESOFTCODE"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获取 其他科目代码 ,用于给科目列表combox提供store
|
|
|
|
|
|
static public List<AccitemsModel> GetAccitems(string strUserID)
|
|
|
{
|
|
|
return GetAccitems(string.Empty, strUserID);
|
|
|
}
|
|
|
|
|
|
static public List<AccitemsModel> GetAccitems(string strCondition, string strUserID)
|
|
|
{
|
|
|
string strCwACCDATE = GetCwACCDATE(strUserID);
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select GID,ACCID,ACCNAME,ACCID+'-'+ACCNAME AS ACCIDNAME,DC,ISFCY,REMARKS,DETAILED,ISFCY,ISDEPTACC,ISEMPLACC,ISCORPACC,ISITEMACC from cw_accitems where ([year]=SUBSTRING('" + strCwACCDATE + "',1,4) or [year]='' or [year] is null)");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" order by ACCID ");
|
|
|
return SetAccitems(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<AccitemsModel> SetAccitems(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<AccitemsModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
AccitemsModel data = new AccitemsModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.ACCID = Convert.ToString(reader["ACCID"]);
|
|
|
data.ACCNAME = Convert.ToString(reader["ACCNAME"]);
|
|
|
data.ACCIDNAME = Convert.ToString(reader["ACCIDNAME"]);
|
|
|
data.DC = Convert.ToString(reader["DC"]);
|
|
|
data.REMARKS = Convert.ToString(reader["REMARKS"]);
|
|
|
data.DETAILED = Convert.ToString(reader["DETAILED"]);
|
|
|
data.ISFCY = Convert.ToBoolean(reader["ISFCY"]);
|
|
|
data.ISDEPTACC = Convert.ToBoolean(reader["ISDEPTACC"]);
|
|
|
data.ISEMPLACC = Convert.ToBoolean(reader["ISEMPLACC"]);
|
|
|
data.ISCORPACC = Convert.ToBoolean(reader["ISCORPACC"]);
|
|
|
data.ISITEMACC = Convert.ToBoolean(reader["ISITEMACC"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<AccitemsModel> GetMngAccitems(string strCondition)
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select GID,ACCID,ACCNAME,ACCID+'-'+ACCNAME AS ACCIDNAME,DC,ISFCY,REMARKS,DETAILED,ISFCY,ISDEPTACC,ISEMPLACC,ISCORPACC,ISITEMACC from cw_accitems where 1=1 ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
return SetAccitems(strSql);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 查询用户权限
|
|
|
|
|
|
static public List<AuthorityRangemb> GetAR(string modName, string USERID)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" select GID,visiblerange,operaterange from user_authority_range where authorityid=( ");
|
|
|
strSql.Append(" select gid from user_authority_info where (name='" + modName + "' or DESCRIPTION='" + modName + "') and isdelete=0 ");
|
|
|
strSql.Append(" and userid='" + USERID + "') ");
|
|
|
return SetAR(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<AuthorityRangemb> SetAR(StringBuilder strSql)
|
|
|
{
|
|
|
var bodyList = new List<AuthorityRangemb>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
AuthorityRangemb data = new AuthorityRangemb();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.VISIBLERANGE = Convert.ToString(reader["VISIBLERANGE"]);
|
|
|
data.OPERATERANGE = Convert.ToString(reader["OPERATERANGE"]);
|
|
|
#endregion
|
|
|
|
|
|
bodyList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return bodyList;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获得可视范围的查询子句。相关字段存储的应当都是相应ID
|
|
|
/// </summary>
|
|
|
/// <param name="modName">权限名字 user_authority_info.NAME</param>
|
|
|
/// <param name="USERID"></param>
|
|
|
/// <param name="COMPANYFIELDNAME">用于查询语句中的,公司ID的字段或表达式 SQL层面的</param>
|
|
|
/// <param name="USERFIELD">用于查询语句中的,人的ID的字段或表达式 SQL层面的</param>
|
|
|
/// <param name="DEPTFIELDNAME">用于查询语句中的,部门的ID的字段或表达式 SQL层面的</param>
|
|
|
/// <returns></returns>
|
|
|
public static string GetVisableRange(string modName, string USERID, string COMPANYFIELDNAME, string USERFIELD = "", string DEPTFIELDNAME = "")
|
|
|
{
|
|
|
var evList = BasicDataRefDAL.GetAR(modName, USERID);
|
|
|
AuthorityRangemb head = null;
|
|
|
|
|
|
var result = "";
|
|
|
|
|
|
var VISIBLERANGE = "3";
|
|
|
|
|
|
if (evList.Count > 0)
|
|
|
head = evList[0];
|
|
|
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new AuthorityRangemb();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
VISIBLERANGE = head.VISIBLERANGE;
|
|
|
}
|
|
|
|
|
|
//0 全部
|
|
|
if (VISIBLERANGE == "0")
|
|
|
{
|
|
|
result = "1=1";
|
|
|
}
|
|
|
else
|
|
|
if (VISIBLERANGE == "1")
|
|
|
{//1 分公司
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = COMPANYFIELDNAME + " in (select companyid from vw_user where userid='" + USERID + "')";
|
|
|
}
|
|
|
else if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
{
|
|
|
result = USERFIELD + " in (select USERID from vw_user where companyid =(select companyid from vw_user where userid='" + USERID + "'))";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (VISIBLERANGE == "2")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = DEPTFIELDNAME + " in (select deptgid from vw_user where userid='" + USERID + "')";
|
|
|
}
|
|
|
else if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
{
|
|
|
result = USERFIELD + " in (select USERID from vw_user where deptgid =(select deptgid from vw_user where userid='" + USERID + "'))";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (VISIBLERANGE == "3")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
{
|
|
|
result = USERFIELD + " ='" + USERID + "' ";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (VISIBLERANGE == "4")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
{
|
|
|
result = "1=2";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (VISIBLERANGE == "5")
|
|
|
{//选择公司
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = COMPANYFIELDNAME + " in(select COMPANYID from user_authority_range_company where userid='"
|
|
|
+ USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)";
|
|
|
}
|
|
|
else if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
{
|
|
|
result = USERFIELD + " in(select USERID from vw_user where companyid in(select COMPANYID from user_authority_range_company where userid='"
|
|
|
+ USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (VISIBLERANGE == "6")
|
|
|
{//选择个人
|
|
|
if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
{
|
|
|
result = USERFIELD + " in(select OPID from user_authority_range_op where userid='"
|
|
|
+ USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (head == null || result == "")
|
|
|
{
|
|
|
result = "1=2";
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 可操作范围查询子句
|
|
|
/// </summary>
|
|
|
/// <param name="modName"></param>
|
|
|
/// <param name="USERID"></param>
|
|
|
/// <param name="COMPANYFIELDNAME"></param>
|
|
|
/// <param name="USERFIELD"></param>
|
|
|
/// <param name="DEPTFIELDNAME"></param>
|
|
|
/// <returns></returns>
|
|
|
public static string GetOperateRange(string modName, string USERID, string COMPANYFIELDNAME, string USERFIELD = "", string DEPTFIELDNAME = "")
|
|
|
{
|
|
|
var evList = BasicDataRefDAL.GetAR(modName, USERID);
|
|
|
AuthorityRangemb head = null;
|
|
|
|
|
|
var result = "";
|
|
|
|
|
|
var OPERATERANGE = "3";
|
|
|
|
|
|
if (evList.Count > 0)
|
|
|
head = evList[0];
|
|
|
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new AuthorityRangemb();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
OPERATERANGE = head.OPERATERANGE;
|
|
|
}
|
|
|
|
|
|
//0 全部
|
|
|
if (OPERATERANGE == "0")
|
|
|
{
|
|
|
result = "1=1";
|
|
|
}
|
|
|
else
|
|
|
if (OPERATERANGE == "1")
|
|
|
{//1 分公司
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = COMPANYFIELDNAME + " in(select companyid from vw_user where userid='" + USERID + "')";
|
|
|
}
|
|
|
else if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
{
|
|
|
result = USERFIELD + " in(select USERID from vw_user where companyid =(select companyid from vw_user where userid='" + USERID + "'))";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (OPERATERANGE == "2")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = DEPTFIELDNAME + " in(select deptid from vw_user where userid='" + USERID + "')";
|
|
|
}
|
|
|
else if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
{
|
|
|
result = USERFIELD + " in(select USERID from vw_user where deptid =(select deptid from vw_user where userid='" + USERID + "'))";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (OPERATERANGE == "3")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
{
|
|
|
result = USERFIELD + " ='" + USERID + "' ";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (OPERATERANGE == "4")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
{
|
|
|
result = "1=2";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (OPERATERANGE == "5")
|
|
|
{//选择公司
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = COMPANYFIELDNAME + " in(select COMPANYID from user_authority_range_company where userid='"
|
|
|
+ USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)";
|
|
|
}
|
|
|
else if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
{
|
|
|
result = USERFIELD + " in(select USERID from vw_user where companyid in(select COMPANYID from user_authority_range_company where userid='"
|
|
|
+ USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (OPERATERANGE == "6")
|
|
|
{//选择个人
|
|
|
if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
{
|
|
|
result = USERFIELD + " in(select OPID from user_authority_range_op where userid='"
|
|
|
+ USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (head == null || result == "")
|
|
|
{
|
|
|
result = "1=2";
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 组织权限语句的方法 通用版(目前内贸和运价报价模块使用)
|
|
|
/// </summary>
|
|
|
/// <param name="modName"></param>
|
|
|
/// <param name="USERID"></param>
|
|
|
/// <param name="COMPANYFIELDNAME"></param>
|
|
|
/// <param name="USERFIELDArray"></param>
|
|
|
/// <param name="DEPTFIELDNAME"></param>
|
|
|
/// <returns></returns>
|
|
|
public static string GetRangeCondition(RangeType rangetype, string modName, string USERID, string COMPANYFIELDNAME, string[] USERFIELDArray, string DEPTFIELDNAME = "")
|
|
|
{
|
|
|
var RANGENAME = "";
|
|
|
|
|
|
if (rangetype == RangeType.Visable)
|
|
|
{
|
|
|
RANGENAME = "VISIBLERANGE";
|
|
|
}
|
|
|
if (rangetype == RangeType.Operate)
|
|
|
{
|
|
|
RANGENAME = "OPERATERANGE";
|
|
|
}
|
|
|
|
|
|
if (RANGENAME == "") return " 1=2 ";
|
|
|
|
|
|
|
|
|
var evList = BasicDataRefDAL.GetAR(modName, USERID);
|
|
|
if (evList.Count == 0) return " 1=2 ";
|
|
|
|
|
|
AuthorityRangemb head = null;
|
|
|
|
|
|
var result = "";
|
|
|
|
|
|
var RANGEVALUE = "3";
|
|
|
|
|
|
if (evList.Count > 0)
|
|
|
head = evList[0];
|
|
|
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new AuthorityRangemb();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (rangetype == RangeType.Visable)
|
|
|
{
|
|
|
RANGEVALUE = head.VISIBLERANGE;
|
|
|
}
|
|
|
if (rangetype == RangeType.Operate)
|
|
|
{
|
|
|
RANGEVALUE = head.OPERATERANGE;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//0 全部
|
|
|
if (RANGEVALUE == "0")
|
|
|
{
|
|
|
result = "1=1";
|
|
|
}
|
|
|
else
|
|
|
if (RANGEVALUE == "1")
|
|
|
{//1 分公司
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = COMPANYFIELDNAME + " in(select top 1 companyid from vw_user where userid='" + USERID + "' or showname='" + USERID + "')";
|
|
|
}
|
|
|
else if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + USERFIELD + " in( select USERID from vw_user where companyid in(select companyid from vw_user where userid='" + USERID + "' or showname='" + USERID + "')" +
|
|
|
" union all select SHOWNAME from vw_user where companyid in(select top 1 companyid from vw_user where userid = '" + USERID + "' or showname = '" + USERID + "'))";
|
|
|
}
|
|
|
result = "(" + _S + ")";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (RANGEVALUE == "2")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = COMPANYFIELDNAME + " in(select top 1 companyid from vw_user where userid='" + USERID + "' or showname='" + USERID + "')";
|
|
|
result += " and " + DEPTFIELDNAME + " in(select top 1 deptgid from vw_user where userid='" + USERID + "' or showname='" + USERID + "' union all select top 1 deptname from vw_user where userid='" + USERID + "' or showname='" + USERID + "' ) ";
|
|
|
}
|
|
|
else if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + USERFIELD + " in( select USERID from vw_user where deptgid in(select deptgid from vw_user where userid='" + USERID + "' or showname='" + USERID + "')" +
|
|
|
"union all select SHOWNAME from vw_user where deptgid in(select deptgid from vw_user where userid = '" + USERID + "' or showname = '" + USERID + "'))";
|
|
|
}
|
|
|
result = "(" + _S + ")";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
if (RANGEVALUE == "3")
|
|
|
{
|
|
|
if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
//result = USERFIELD + " ='" + USERID + "' ";
|
|
|
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + USERFIELD + " ='" + USERID + "' or " + USERFIELD + " =( select SHOWNAME from vw_user where USERID in(select USERID from vw_user where userid = '" + USERID + "' or showname = '" + USERID + "'))";
|
|
|
}
|
|
|
result = "(" + _S + ")";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (RANGEVALUE == "4")
|
|
|
{
|
|
|
if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
result = "1=2";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (RANGEVALUE == "5")
|
|
|
{//选择公司
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = COMPANYFIELDNAME + " in(select COMPANYID from user_authority_range_company where AUTHORITYID=(select GID from user_authority_info where Name='" + modName + "' or DESCRIPTION='" + modName + "') and " + RANGENAME + " = 1)";
|
|
|
}
|
|
|
else if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + " exists(select 1 from vw_user where companyid in " +
|
|
|
"(select companyid from user_authority_range_company where AUTHORITYID = " +
|
|
|
"(select GID from user_authority_info where Name = '" + modName + "' or DESCRIPTION = '" + modName + "') and " + RANGENAME + " = 1 " +
|
|
|
") and(userid = " + USERFIELD + " or SHOWNAME = " + USERFIELD + "))";
|
|
|
}
|
|
|
result = "(" + _S + ")";
|
|
|
|
|
|
|
|
|
//result = USERFIELD + " in(select USERID from vw_user where companyid in(select COMPANYID from user_authority_range_company where userid='"
|
|
|
// + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (RANGEVALUE == "6")
|
|
|
{//选择个人
|
|
|
if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + USERFIELD + " in(select OPID from user_authority_range_op where userid = (select userid from vw_user where userid = '" + USERID + "'" +
|
|
|
"or showname = '" + USERID + "') and AUTHORITYID = (select GID from user_authority_info where name = '" + modName + "' or description = '" + modName + "')" +
|
|
|
"and " + RANGENAME + " = 1 union all select showname from vw_user where userid in(select OPID from user_authority_range_op where userid = (select userid from vw_user where userid = '" + USERID + "'" +
|
|
|
" or showname = '" + USERID + "') and AUTHORITYID = (select GID from user_authority_info where name = '" + modName + "' or description = '" + modName + "') and " + RANGENAME + " = 1))";
|
|
|
}
|
|
|
result = "(" + _S + ")";
|
|
|
|
|
|
//result = USERFIELD + " in(select OPID from user_authority_range_op where userid='"
|
|
|
// + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (head == null || result == "")
|
|
|
{
|
|
|
result = "1=2";
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public enum RangeType
|
|
|
{
|
|
|
Visable,
|
|
|
Operate
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获得可视范围的查询子句。相关字段存储的 user或dept可以是相应ID或中文名 company必须是ID
|
|
|
/// var rangestr = BasicDataRefDAL.GetVisableRange("modYAXIANG", USERID, "COMPANYID", new string[]{ "CREATEUSER"}, "DEPTID");
|
|
|
/// </summary>
|
|
|
/// <param name="modName">权限名字 user_authority_info.NAME或description</param>
|
|
|
/// <param name="USERID"></param>
|
|
|
/// <param name="COMPANYFIELDNAME">用于查询语句中的,公司ID的字段或表达式 SQL层面的</param>
|
|
|
/// <param name="USERFIELD">用于查询语句中的,人的ID的字段或表达式 SQL层面的</param>
|
|
|
/// <param name="DEPTFIELDNAME">用于查询语句中的,部门的ID的字段或表达式 SQL层面的</param>
|
|
|
/// <returns></returns>
|
|
|
public static string GetVisableRange2(string modName, string USERID, string COMPANYFIELDNAME, string[] USERFIELDArray, string DEPTFIELDNAME = "")
|
|
|
{
|
|
|
var evList = BasicDataRefDAL.GetAR(modName, USERID);
|
|
|
AuthorityRangemb head = null;
|
|
|
|
|
|
var result = "";
|
|
|
|
|
|
var VISIBLERANGE = "3";
|
|
|
|
|
|
if (evList.Count > 0)
|
|
|
head = evList[0];
|
|
|
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new AuthorityRangemb();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
VISIBLERANGE = head.VISIBLERANGE;
|
|
|
}
|
|
|
|
|
|
//0 全部
|
|
|
if (VISIBLERANGE == "0")
|
|
|
{
|
|
|
result = "1=1";
|
|
|
}
|
|
|
else
|
|
|
if (VISIBLERANGE == "1")
|
|
|
{//1 分公司
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = COMPANYFIELDNAME + " in(select companyid from vw_user where userid='" + USERID + "' or showname='" + USERID + "')";
|
|
|
}
|
|
|
else if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + USERFIELD + " in( select USERID from vw_user where companyid in(select companyid from vw_user where userid='" + USERID + "' or showname='" + USERID + "')" +
|
|
|
" union all select SHOWNAME from vw_user where companyid in(select companyid from vw_user where userid = '" + USERID + "' or showname = '" + USERID + "'))";
|
|
|
}
|
|
|
result = _S;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (VISIBLERANGE == "2")
|
|
|
{//限定部门 此时dept参数必须要有
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = COMPANYFIELDNAME + " in(select companyid from vw_user where userid='" + USERID + "' or showname='" + USERID + "')";
|
|
|
result += " and " + DEPTFIELDNAME + " in(select deptgid from vw_user where userid='" + USERID + "' or showname='" + USERID + "' union all select deptname from vw_user where userid='" + USERID + "' or showname='" + USERID + "' ) ";
|
|
|
}
|
|
|
else if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + USERFIELD + " in( select USERID from vw_user where deptgid in(select deptgid from vw_user where userid='" + USERID + "' or showname='" + USERID + "')" +
|
|
|
"union all select SHOWNAME from vw_user where deptgid in(select deptgid from vw_user where userid = '" + USERID + "' or showname = '" + USERID + "'))";
|
|
|
}
|
|
|
result = _S;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
if (VISIBLERANGE == "3")
|
|
|
{
|
|
|
if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
//result = USERFIELD + " ='" + USERID + "' ";
|
|
|
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + USERFIELD + " ='" + USERID + "' or " + USERFIELD + " =( select SHOWNAME from vw_user where USERID in(select USERID from vw_user where userid = '" + USERID + "' or showname = '" + USERID + "'))";
|
|
|
}
|
|
|
result = _S;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (VISIBLERANGE == "4")
|
|
|
{
|
|
|
if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
result = "1=2";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (VISIBLERANGE == "5")
|
|
|
{//选择公司
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = COMPANYFIELDNAME + " in(select COMPANYID from user_authority_range_company where AUTHORITYID=(select GID from user_authority_info where Name='" + modName + "' or DESCRIPTION='" + modName + "') and VISIBLERANGE = 1)";
|
|
|
}
|
|
|
else if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + " exists(select 1 from vw_user where companyid in " +
|
|
|
"(select companyid from user_authority_range_company where AUTHORITYID = " +
|
|
|
"(select GID from user_authority_info where Name = '" + modName + "' or DESCRIPTION = '" + modName + "') and VISIBLERANGE = 1 " +
|
|
|
") and(userid = " + USERFIELD + " or SHOWNAME = " + USERFIELD + "))";
|
|
|
}
|
|
|
result = _S;
|
|
|
|
|
|
|
|
|
//result = USERFIELD + " in(select USERID from vw_user where companyid in(select COMPANYID from user_authority_range_company where userid='"
|
|
|
// + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (VISIBLERANGE == "6")
|
|
|
{//选择个人
|
|
|
if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + USERFIELD + " in(select OPID from user_authority_range_op where userid = (select userid from vw_user where userid = '" + USERID + "'" +
|
|
|
"or showname = '" + USERID + "') and AUTHORITYID = (select GID from user_authority_info where name = '" + modName + "' or description = '" + modName + "')" +
|
|
|
"and VISIBLERANGE = 1 union all select showname from vw_user where userid in(select OPID from user_authority_range_op where userid = (select userid from vw_user where userid = '" + USERID + "'" +
|
|
|
" or showname = '" + USERID + "') and AUTHORITYID = (select GID from user_authority_info where name = '" + modName + "' or description = '" + modName + "') and VISIBLERANGE = 1))";
|
|
|
}
|
|
|
result = _S;
|
|
|
|
|
|
//result = USERFIELD + " in(select OPID from user_authority_range_op where userid='"
|
|
|
// + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (head == null || result == "")
|
|
|
{
|
|
|
result = "1=2";
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 可操作范围查询子句
|
|
|
/// </summary>
|
|
|
/// <param name="modName"></param>
|
|
|
/// <param name="USERID"></param>
|
|
|
/// <param name="COMPANYFIELDNAME"></param>
|
|
|
/// <param name="USERFIELD"></param>
|
|
|
/// <param name="DEPTFIELDNAME"></param>
|
|
|
/// <returns></returns>
|
|
|
public static string GetOperateRange2(string modName, string USERID, string COMPANYFIELDNAME, string[] USERFIELDArray, string DEPTFIELDNAME = "")
|
|
|
{
|
|
|
var evList = BasicDataRefDAL.GetAR(modName, USERID);
|
|
|
AuthorityRangemb head = null;
|
|
|
|
|
|
var result = "";
|
|
|
|
|
|
var OPERATERANGE = "3";
|
|
|
|
|
|
if (evList.Count > 0)
|
|
|
head = evList[0];
|
|
|
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new AuthorityRangemb();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
OPERATERANGE = head.OPERATERANGE;
|
|
|
}
|
|
|
|
|
|
//0 全部
|
|
|
if (OPERATERANGE == "0")
|
|
|
{
|
|
|
result = "1=1";
|
|
|
}
|
|
|
else
|
|
|
if (OPERATERANGE == "1")
|
|
|
{//1 分公司
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = COMPANYFIELDNAME + " in(select companyid from vw_user where userid='" + USERID + "' or showname='" + USERID + "')";
|
|
|
}
|
|
|
else if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + USERFIELD + " in( select USERID from vw_user where companyid in(select companyid from vw_user where userid='" + USERID + "' or showname='" + USERID + "')" +
|
|
|
" union all select SHOWNAME from vw_user where companyid in(select companyid from vw_user where userid = '" + USERID + "' or showname = '" + USERID + "'))";
|
|
|
}
|
|
|
result = _S;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (OPERATERANGE == "2")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = COMPANYFIELDNAME + " in(select companyid from vw_user where userid='" + USERID + "' or showname='" + USERID + "')";
|
|
|
result += " and " + DEPTFIELDNAME + " in(select deptgid from vw_user where userid='" + USERID + "' or showname='" + USERID + "' union all select deptname from vw_user where userid='" + USERID + "' or showname='" + USERID + "' ) ";
|
|
|
}
|
|
|
else if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + USERFIELD + " in( select USERID from vw_user where deptgid in(select deptgid from vw_user where userid='" + USERID + "' or showname='" + USERID + "')" +
|
|
|
"union all select SHOWNAME from vw_user where deptgid in(select deptgid from vw_user where userid = '" + USERID + "' or showname = '" + USERID + "'))";
|
|
|
}
|
|
|
result = _S;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
else
|
|
|
if (OPERATERANGE == "3")
|
|
|
{
|
|
|
if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
//result = USERFIELD + " ='" + USERID + "' ";
|
|
|
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + USERFIELD + " ='" + USERID + "' or " + USERFIELD + " =( select SHOWNAME from vw_user where USERID in(select USERID from vw_user where userid = '" + USERID + "' or showname = '" + USERID + "'))";
|
|
|
}
|
|
|
result = _S;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (OPERATERANGE == "4")
|
|
|
{
|
|
|
if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
result = "1=2";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (OPERATERANGE == "5")
|
|
|
{//选择公司
|
|
|
if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
{
|
|
|
result = COMPANYFIELDNAME + " in(select COMPANYID from user_authority_range_company where AUTHORITYID=(select GID from user_authority_info where Name='" + modName + "' or DESCRIPTION='" + modName + "') and OPERATERANGE = 1)";
|
|
|
}
|
|
|
else if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + " exists(select 1 from vw_user where companyid in " +
|
|
|
"(select companyid from user_authority_range_company where AUTHORITYID = " +
|
|
|
"(select GID from user_authority_info where Name = '" + modName + "' or DESCRIPTION = '" + modName + "') and OPERATERANGE = 1 " +
|
|
|
") and(userid = " + USERFIELD + " or SHOWNAME = " + USERFIELD + "))";
|
|
|
}
|
|
|
result = _S;
|
|
|
|
|
|
|
|
|
//result = USERFIELD + " in(select USERID from vw_user where companyid in(select COMPANYID from user_authority_range_company where userid='"
|
|
|
// + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and OPERATERANGE=1)";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (OPERATERANGE == "6")
|
|
|
{//选择个人
|
|
|
if (USERFIELDArray.Length > 0)
|
|
|
{
|
|
|
var _S = "";
|
|
|
foreach (var USERFIELD in USERFIELDArray)
|
|
|
{
|
|
|
if (_S != "") _S += " or ";
|
|
|
_S = _S + USERFIELD + " in(select OPID from user_authority_range_op where userid = (select userid from vw_user where userid = '" + USERID + "'" +
|
|
|
"or showname = '" + USERID + "') and AUTHORITYID = (select GID from user_authority_info where name = '" + modName + "' or description = '" + modName + "')" +
|
|
|
"and OPERATERANGE = 1 union all select showname from vw_user where userid in(select OPID from user_authority_range_op where userid = (select userid from vw_user where userid = '" + USERID + "'" +
|
|
|
" or showname = '" + USERID + "') and AUTHORITYID = (select GID from user_authority_info where name = '" + modName + "' or description = '" + modName + "') and OPERATERANGE = 1))";
|
|
|
}
|
|
|
result = _S;
|
|
|
|
|
|
//result = USERFIELD + " in(select OPID from user_authority_range_op where userid='"
|
|
|
// + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and OPERATERANGE=1)";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#region 旧的单关键字段算法
|
|
|
//else
|
|
|
//if (OPERATERANGE == "1")
|
|
|
//{//1 分公司
|
|
|
// if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
// {
|
|
|
// result = COMPANYFIELDNAME + " in(select companyid from vw_user where userid='" + USERID + "')";
|
|
|
// }
|
|
|
// else if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
// {
|
|
|
// result = USERFIELD + " in(select USERID from vw_user where companyid =(select companyid from vw_user where userid='" + USERID + "'))";
|
|
|
// }
|
|
|
//}
|
|
|
//else
|
|
|
//if (OPERATERANGE == "2")
|
|
|
//{
|
|
|
// if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
// {
|
|
|
// result = DEPTFIELDNAME + " in(select deptid from vw_user where userid='" + USERID + "')";
|
|
|
// }
|
|
|
// else if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
// {
|
|
|
// result = USERFIELD + " in(select USERID from vw_user where deptid =(select deptid from vw_user where userid='" + USERID + "'))";
|
|
|
// }
|
|
|
//}
|
|
|
//else
|
|
|
//if (OPERATERANGE == "3")
|
|
|
//{
|
|
|
// if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
// {
|
|
|
// result = USERFIELD + " ='" + USERID + "' ";
|
|
|
// }
|
|
|
//}
|
|
|
//else
|
|
|
//if (OPERATERANGE == "4")
|
|
|
//{
|
|
|
// if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
// {
|
|
|
// result = "1=2";
|
|
|
// }
|
|
|
//}
|
|
|
//else
|
|
|
//if (OPERATERANGE == "5")
|
|
|
//{//选择公司
|
|
|
// if (!string.IsNullOrEmpty(COMPANYFIELDNAME))
|
|
|
// {
|
|
|
// result = COMPANYFIELDNAME + " in(select COMPANYID from user_authority_range_company where userid='"
|
|
|
// + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and OPERATERANGE=1)";
|
|
|
// }
|
|
|
// else if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
// {
|
|
|
// result = USERFIELD + " in(select USERID from vw_user where companyid in(select COMPANYID from user_authority_range_company where userid='"
|
|
|
// + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and OPERATERANGE=1)";
|
|
|
// }
|
|
|
//}
|
|
|
//else
|
|
|
//if (OPERATERANGE == "6")
|
|
|
//{//选择个人
|
|
|
// if (!string.IsNullOrEmpty(USERFIELD))
|
|
|
// {
|
|
|
// result = USERFIELD + " in(select OPID from user_authority_range_op where userid='"
|
|
|
// + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and OPERATERANGE=1)";
|
|
|
// }
|
|
|
//}
|
|
|
#endregion
|
|
|
|
|
|
if (head == null || result == "")
|
|
|
{
|
|
|
result = "1=2";
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 返回查询子句
|
|
|
/// 用于判断USERID是否具有对【head这条业务】的【ModName权限】的使用权
|
|
|
/// </summary>
|
|
|
/// <param name="head"></param>
|
|
|
/// <param name="ModName"></param>
|
|
|
/// <returns></returns>
|
|
|
public static string CanOperateStr_INVOICE(string ModName, string USERID)
|
|
|
{
|
|
|
|
|
|
var rangestr = BasicDataRefDAL.GetOperateRange(ModName, USERID, "COMPANYID", "OPERATOR");
|
|
|
return rangestr;
|
|
|
}
|
|
|
|
|
|
//public class USERINFO {
|
|
|
// public string USERID { get; set; }
|
|
|
// public string USERID { get; set; }
|
|
|
// public string USERID { get; set; }
|
|
|
// public string USERID { get; set; }
|
|
|
|
|
|
// public USERINFO(HttpSessionStateBase CurrSession) {
|
|
|
// new USERINFO(CurrSession["USERID"].ToString(), CurrSession["SHOWNAME"].ToString(), CurrSession["COMPANYID"].ToString(), CurrSession["DEPTNAME"].ToString());
|
|
|
// }
|
|
|
// public USERINFO(string USERID, string SHOWNAME, string COMPANYID, string DEPTNAME) {
|
|
|
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取本部门领取且未支取的支票号
|
|
|
|
|
|
static public List<CHEQUENUMmb> GetUnusedCHEQUENUM(string DEPTID, string BXGID)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" select '外代IC卡' chequeno union all ");
|
|
|
strSql.Append(" select '外运IC卡' chequeno union all ");
|
|
|
strSql.Append(" select '挂账' chequeno union all ");
|
|
|
strSql.Append(" select chequeno from( ");
|
|
|
strSql.Append(" select cfc.chequeno,bxgid from ch_fee_cheque cfc ");
|
|
|
strSql.Append(" left join ch_fee on ch_fee.chequenum=cfc.chequeno ");
|
|
|
strSql.Append(" where cfc.billno in (select gid from OA_Jiekuan where deptid='" + DEPTID + "') ");
|
|
|
strSql.Append(" and cfc.chequeno is not null and cfc.chequeno<>'')t ");
|
|
|
strSql.Append(" where bxgid is null or bxgid='" + BXGID + "' ");
|
|
|
return SetUnusedCHEQUENUM(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<CHEQUENUMmb> SetUnusedCHEQUENUM(StringBuilder strSql)
|
|
|
{
|
|
|
var bodyList = new List<CHEQUENUMmb>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CHEQUENUMmb data = new CHEQUENUMmb();
|
|
|
#region Set DB data to Object
|
|
|
data.CHEQUENUM = Convert.ToString(reader["CHEQUENO"]);
|
|
|
#endregion
|
|
|
|
|
|
bodyList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return bodyList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取工作流typeno 用于在工作流管理界面选择typeno
|
|
|
|
|
|
static public List<WorkFlowmb> GetTYPENO(string condition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" select GID,name+'_'+description as name,typeno from workflow_type ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" where " + condition);
|
|
|
}
|
|
|
return SetTYPENO(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<WorkFlowmb> SetTYPENO(StringBuilder strSql)
|
|
|
{
|
|
|
var bodyList = new List<WorkFlowmb>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
WorkFlowmb data = new WorkFlowmb();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.NAME = Convert.ToString(reader["NAME"]);
|
|
|
data.TYPENO = Convert.ToString(reader["TYPENO"]);
|
|
|
#endregion
|
|
|
|
|
|
bodyList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return bodyList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 通过工作流名字查找工作流编号
|
|
|
/*
|
|
|
static public List<WorkFlowmb> GetWorkFlowID(string NAME, string OrgCode)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" select GID,[Name] from workflow where ");
|
|
|
strSql.Append(" [type]=(select typeno from workflow_type where name= '" + NAME + "') ");
|
|
|
strSql.Append(" and companyid=(select gid from company where codename='" + OrgCode + "' ) ");
|
|
|
|
|
|
return SetWorkFlowID(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<WorkFlowmb> SetWorkFlowID(StringBuilder strSql)
|
|
|
{
|
|
|
var bodyList = new List<WorkFlowmb>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
WorkFlowmb data = new WorkFlowmb();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.NAME = Convert.ToString(reader["NAME"]);
|
|
|
#endregion
|
|
|
|
|
|
bodyList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return bodyList;
|
|
|
}*/
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 通过workflow_type.name,userid查找workflow_step的内容
|
|
|
|
|
|
static public List<DSWeb.Areas.CommMng.Models.WorkFlowStepmb> GetWorkFlowStep(string WorkFlowName, string UserID)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" select * from workflow_step where WORKFLOWID in ");
|
|
|
strSql.Append(" (select gid from workflow where [type]=(select [typeno] from workflow_type where [name]='" + WorkFlowName + "')) ");
|
|
|
strSql.Append(" and AUDITOR='" + UserID + "' order by STEPNO");
|
|
|
|
|
|
return SetWorkFlowStep(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<DSWeb.Areas.CommMng.Models.WorkFlowStepmb> SetWorkFlowStep(StringBuilder strSql)
|
|
|
{
|
|
|
var bodyList = new List<DSWeb.Areas.CommMng.Models.WorkFlowStepmb>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
DSWeb.Areas.CommMng.Models.WorkFlowStepmb data = new DSWeb.Areas.CommMng.Models.WorkFlowStepmb();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.NAME = Convert.ToString(reader["NAME"]);
|
|
|
data.STEPNO = Convert.ToString(reader["STEPNO"]);
|
|
|
data.NEEDALLPASS = Convert.ToString(reader["NEEDALLPASS"]);
|
|
|
data.ISMUST = Convert.ToString(reader["ISMUST"]);
|
|
|
data.ISLAST = Convert.ToString(reader["ISLAST"]);
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
bodyList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return bodyList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取该用户,在该工作流程的该步骤中 可以操作的业务编号列表
|
|
|
/*
|
|
|
static public List<WorkFlow_Usingmb> GetWorkFlowState(string WorkFlowID, int StepNo, string USERID)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" select * from workflow_using ");
|
|
|
strSql.Append(" where workflowid='" + WorkFlowID + "' ");
|
|
|
strSql.Append(" and stepno=( ");
|
|
|
strSql.Append(" select stepno from workflow_step ");
|
|
|
strSql.Append(" where workflowid='" + WorkFlowID + "' ");
|
|
|
strSql.Append(" and auditor='" + USERID + "' ");
|
|
|
|
|
|
strSql.Append(" and stepno=" + StepNo.ToString() + ") ");
|
|
|
|
|
|
return SetWorkFlowState(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<WorkFlow_Usingmb> SetWorkFlowState(StringBuilder strSql)
|
|
|
{
|
|
|
var bodyList = new List<WorkFlow_Usingmb>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
WorkFlow_Usingmb data = new WorkFlow_Usingmb();
|
|
|
#region Set DB data to Object
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
data.WORKFLOWID = Convert.ToString(reader["WORKFLOWID"]);
|
|
|
data.STEPNO = Convert.ToString(reader["STEPNO"]);
|
|
|
data.REJECTOR_ID = Convert.ToString(reader["REJECTOR_ID"]);
|
|
|
data.REJECT_TIME = Convert.ToString(reader["REJECT_TIME"]);
|
|
|
data.FINISHED = Convert.ToString(reader["FINISHED"]);
|
|
|
data.ISDELETE = Convert.ToString(reader["ISDELETE"]);
|
|
|
data.DELETEUSER = Convert.ToString(reader["DELETEUSER"]);
|
|
|
data.DELETETIME = Convert.ToString(reader["DELETETIME"]);
|
|
|
#endregion
|
|
|
|
|
|
bodyList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return bodyList;
|
|
|
}
|
|
|
*/
|
|
|
#endregion
|
|
|
|
|
|
#region 键值维护表 crm_key_code
|
|
|
static public List<CrmKeyCodeModel> GetCrmKeyCodeList(string strCondition,string LAN)
|
|
|
{
|
|
|
String strSql = "SELECT ID as GID,KEYTYPE,KEYVALUE,KEYVALUE2 from crm_key_code ";
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql += " where 1=1 " + strCondition;
|
|
|
}
|
|
|
return SetCrmKeyCodeData(strSql, LAN);
|
|
|
}
|
|
|
|
|
|
private static List<CrmKeyCodeModel> SetCrmKeyCodeData(String strSql, string LAN)
|
|
|
{
|
|
|
var headList = new List<CrmKeyCodeModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CrmKeyCodeModel data = new CrmKeyCodeModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.KEYTYPE = Convert.ToString(reader["KEYTYPE"]);
|
|
|
if (LAN == "en-us") {
|
|
|
data.KEYVALUE = Convert.ToString(reader["KEYVALUE2"]);
|
|
|
}
|
|
|
else
|
|
|
data.KEYVALUE = Convert.ToString(reader["KEYVALUE"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 品名
|
|
|
|
|
|
static public List<CodeGoodsModel> GetCodeMsdsGoodsList(string condition, string lan)
|
|
|
{
|
|
|
String strSql = "SELECT GID,GOODNAME GOODCODE,(CHEMICALCGOODSNAME+ '-' + GOODNAME+'-'+DCLASS) as CodeAndName,(CHEMICALCGOODSNAME+ '-' + CHEMICALCGOODSNAME) as GOODNAME,'' GoodsTypeGID,'' GoodsTypeName,GOODNAME ename from code_msds ";
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql += " where " + condition;
|
|
|
}
|
|
|
strSql += " order by CodeAndName";
|
|
|
return SetCodeGoodsData(strSql, lan);
|
|
|
}
|
|
|
static public List<CodeGoodsModel> GetCodeGoodsList(string condition, string lan)
|
|
|
{
|
|
|
String strSql = "SELECT GID,GOODCODE,(GOODCODE+'-'+GOODNAME) as CodeAndName,GOODNAME,GoodsTypeGID,GoodsTypeName=(select top 1 GoodsTypeName from code_goodsType where gid=code_goods.GoodsTypeGID),ename from code_goods ";
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql += " where " + condition;
|
|
|
}
|
|
|
strSql += " order by CodeAndName";
|
|
|
return SetCodeGoodsData(strSql, lan);
|
|
|
}
|
|
|
static public List<CodeGoodsModel> GetImportCodeGoodsList(string condition, string lan)
|
|
|
{
|
|
|
String strSql = "SELECT CNNAME GID,CNNAME GOODCODE,CNNAME as CodeAndName,CNNAME GOODNAME,'' GoodsTypeGID,'' GoodsTypeName,CNNAME ename from Import_Cargoname ";
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql += " where " + condition;
|
|
|
}
|
|
|
strSql += " order by CNNAME";
|
|
|
return SetCodeGoodsData(strSql, lan);
|
|
|
}
|
|
|
|
|
|
private static List<CodeGoodsModel> SetCodeGoodsData(String strSql, string lan)
|
|
|
{
|
|
|
var headList = new List<CodeGoodsModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodeGoodsModel data = new CodeGoodsModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);//货物代码
|
|
|
data.GOODCODE = Convert.ToString(reader["GOODCODE"]);//商品编码
|
|
|
if (lan == "en-us")
|
|
|
{
|
|
|
data.GOODNAME = Convert.ToString(reader["ENAME"]);//商品名称
|
|
|
data.CodeAndName = Convert.ToString(reader["ENAME"]);//商品编码
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
data.GOODNAME = Convert.ToString(reader["GOODNAME"]);//商品名称
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);//商品编码
|
|
|
|
|
|
}
|
|
|
data.GoodsTypeGID = Convert.ToString(reader["GoodsTypeGID"]);//
|
|
|
data.GoodsTypeName = Convert.ToString(reader["GoodsTypeName"]);//
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
CodeGoodsModel adata = new CodeGoodsModel();
|
|
|
#region Set DB data to Object
|
|
|
adata.GID = "";//货物代码
|
|
|
adata.CodeAndName = "";//商品编码
|
|
|
adata.GOODCODE = "";//商品编码
|
|
|
adata.GOODNAME = "";//商品名称
|
|
|
adata.GoodsTypeGID = "";
|
|
|
adata.GoodsTypeName = "";
|
|
|
#endregion
|
|
|
headList.Add(adata);
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 品名明细表
|
|
|
static public List<CodeGoodsDetailModel> GetCodeGoodsDetailList(string condition)
|
|
|
{
|
|
|
String strSql = "SELECT *,GOODNAME=(select top 1 GOODNAME from code_goods where gid=code_goods_detail.LINKGID) from code_goods_detail ";
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql += " where " + condition;
|
|
|
}
|
|
|
strSql += " order by GOODSDETAILNAME";
|
|
|
return SetCodeGoodsDetailData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<CodeGoodsDetailModel> SetCodeGoodsDetailData(String strSql)
|
|
|
{
|
|
|
var headList = new List<CodeGoodsDetailModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodeGoodsDetailModel data = new CodeGoodsDetailModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//惟一编号
|
|
|
data.LINKGID = (reader["LINKGID"] == null ? "" : Convert.ToString(reader["LINKGID"]));//品名GID
|
|
|
data.GOODSDETAILNAME = (reader["GOODSDETAILNAME"] == null ? "" : Convert.ToString(reader["GOODSDETAILNAME"]));//品牌名称
|
|
|
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//备注
|
|
|
data.GOODSDETAILPKGS = (reader["GOODSDETAILPKGS"] == null ? 0 : Convert.ToDecimal(reader["GOODSDETAILPKGS"]));//规格件数
|
|
|
data.GOODNAME = (reader["GOODNAME"] == null ? "" : Convert.ToString(reader["GOODNAME"]));//品名
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
CodeGoodsDetailModel adata = new CodeGoodsDetailModel();
|
|
|
#region Set DB data to Object
|
|
|
adata.GID = "";//惟一编号
|
|
|
adata.LINKGID = "";//品名GID
|
|
|
adata.GOODSDETAILNAME = "";//品牌名称
|
|
|
adata.REMARK = "";//备注
|
|
|
adata.GOODSDETAILPKGS = 0;//规格件数
|
|
|
adata.GOODNAME = "";//品名
|
|
|
#endregion
|
|
|
headList.Add(adata);
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 新版键值维护表 tSysEnumValue
|
|
|
static public List<TSysEnumValueDataModel> GetTSysEnumValueList(string strCondition)
|
|
|
{
|
|
|
String strSql = "select *,CodeAndName=(EnumValueID+' | '+EnumValueName) from tSysEnumValue";//需求编号:SR2017081100003
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql += " where LangId=0 " + strCondition;
|
|
|
}
|
|
|
return SetTSysEnumValueData(strSql);
|
|
|
}
|
|
|
|
|
|
static public List<TSysEnumValueDataModel> GetTSysEnumValueListByTypeid(string typeid)
|
|
|
{
|
|
|
String strSql = "select *,CodeAndName=(EnumValueID+' | '+EnumValueName) from tSysEnumValue";//需求编号:SR2017081100003
|
|
|
|
|
|
strSql += " where LangId=0 and enumtypeid='" + typeid + "'";
|
|
|
|
|
|
return SetTSysEnumValueData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<TSysEnumValueDataModel> SetTSysEnumValueData(String strSql)
|
|
|
{
|
|
|
var headList = new List<TSysEnumValueDataModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
TSysEnumValueDataModel data = new TSysEnumValueDataModel();
|
|
|
#region Set DB data to Object
|
|
|
data.EnumValueID = Convert.ToString(reader["EnumValueID"]);//需求编号:SR2017081100003
|
|
|
data.EnumValueName = Convert.ToString(reader["EnumValueName"]);
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);//需求编号:SR2017081100003
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 国际港口(进口装货港、出口卸货港)
|
|
|
static public List<CodeDisportModel> GetCodeDisportList(string condition)
|
|
|
{
|
|
|
String strSql = GetCodeDisportList_Sqlstr(condition);
|
|
|
return SetCodeDisportData(strSql);
|
|
|
}
|
|
|
static public List<CodeDisportModel> GetCodeDisportbyEDICODE(string EDICODE)
|
|
|
{
|
|
|
String strSql = "SELECT *,(PORT+'-'+EDICODE) as CodeAndName,(select LANE from code_lanes where GID=Code_Disport.LANEGID) LANE from Code_Disport where EDICODE='" + EDICODE + "'";
|
|
|
return SetCodeDisportData(strSql);
|
|
|
}
|
|
|
|
|
|
static public List<CodeDisportModel> GetCodeRailwayPortList(string condition)
|
|
|
{
|
|
|
String strSql = "SELECT PORTENAME PORT,PORTCNAME CNAME,'' EDICODE,(PORTENAME+'-'+PORTCNAME) as CodeAndName,'' LANE from code_railwayport where ";
|
|
|
if (condition != "") strSql = strSql + condition;
|
|
|
strSql = strSql + " ORDER BY PORTENAME ";
|
|
|
return SetCodeDisportData(strSql);
|
|
|
}
|
|
|
|
|
|
public static string GetCodeDisportList_Sqlstr(string condition)
|
|
|
{
|
|
|
String strSql = "SELECT *,(PORT+'-'+EDICODE+'('+CNAME+')') as CodeAndName,(select LANE from code_lanes where GID=Code_Disport.LANEGID) LANE from Code_Disport where ";
|
|
|
if (condition != "") strSql = strSql + condition + " and ";
|
|
|
strSql = strSql + " EDICODE<>'' ORDER BY PORT ";
|
|
|
return strSql;
|
|
|
}
|
|
|
|
|
|
public static string GetCodeDisportList_DisplayWithCNAME_Sqlstr(string condition)
|
|
|
{
|
|
|
String strSql = "SELECT *,(PORT+'-'+EDICODE+'-'+CNAME) as CodeAndName,(select LANE from code_lanes where GID=Code_Disport.LANEGID) LANE from Code_Disport where ";
|
|
|
if (condition != "") strSql = strSql + condition + " and ";
|
|
|
strSql = strSql + " EDICODE<>'' ORDER BY PORT ";
|
|
|
return strSql;
|
|
|
}
|
|
|
|
|
|
|
|
|
private static List<CodeDisportModel> SetCodeDisportData(String strSql)
|
|
|
{
|
|
|
var headList = new List<CodeDisportModel>();
|
|
|
#region 在开头插入空值
|
|
|
CodeDisportModel data2 = new CodeDisportModel();
|
|
|
data2.PORT = "";//港口英文名称
|
|
|
data2.CNAME = "";//中文名称
|
|
|
data2.EDICODE = "";//中文名称
|
|
|
data2.CodeAndName = "";//中文名称
|
|
|
data2.LANE = "";//中文名称
|
|
|
headList.Add(data2);
|
|
|
#endregion
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodeDisportModel data = new CodeDisportModel();
|
|
|
#region Set DB data to Object
|
|
|
data.PORT = Convert.ToString(reader["PORT"]);//港口英文名称
|
|
|
data.CNAME = Convert.ToString(reader["CNAME"]);//中文名称
|
|
|
data.EDICODE = Convert.ToString(reader["EDICODE"]);//中文名称
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);//中文名称
|
|
|
data.LANE = Convert.ToString(reader["LANE"]);//航线
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 国内港口(出口装货港、进口卸货港)
|
|
|
|
|
|
static public List<CodeLoadportModel> GetCodeLoadportList(string condition)
|
|
|
{
|
|
|
String strSql = GetCodeLoadportList_Sqlstr(condition);
|
|
|
return SetCodeLoadportData(strSql);
|
|
|
}
|
|
|
|
|
|
public static string GetCodeLoadportList_Sqlstr(string condition)
|
|
|
{
|
|
|
String strSql = "SELECT *,(PORT+'-'+CNAME) as CodeAndName from Code_Loadport WHERE EDICODE<>'' ";
|
|
|
if (condition != "") strSql = strSql + " and " + condition;
|
|
|
return strSql;
|
|
|
}
|
|
|
|
|
|
static public List<CodeLoadportModel> GetCodeLoadportList()
|
|
|
{
|
|
|
String strSql = "SELECT *,(PORT+'-'+CNAME) as CodeAndName from Code_Loadport WHERE EDICODE<>'' ";
|
|
|
return SetCodeLoadportData(strSql);
|
|
|
}
|
|
|
static public List<CodeLoadportModel> GetLoadportbyEDI(string EDICODE)
|
|
|
{
|
|
|
String strSql = "SELECT *,(PORT+'-'+CNAME) as CodeAndName from Code_Loadport WHERE EDICODE='" + EDICODE + "' ";
|
|
|
return SetCodeLoadportData(strSql);
|
|
|
}
|
|
|
private static List<CodeLoadportModel> SetCodeLoadportData(String strSql)
|
|
|
{
|
|
|
var headList = new List<CodeLoadportModel>();
|
|
|
#region 在最开头插入空值
|
|
|
CodeLoadportModel data2 = new CodeLoadportModel();
|
|
|
data2.PORT = "";//港口英文名称
|
|
|
data2.CNAME = "";//中文名称
|
|
|
data2.EDICODE = "";//中文名称
|
|
|
data2.CodeAndName = "";//中文名称
|
|
|
headList.Add(data2);
|
|
|
#endregion
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodeLoadportModel data = new CodeLoadportModel();
|
|
|
#region Set DB data to Object
|
|
|
data.PORT = Convert.ToString(reader["PORT"]);//港口英文名称
|
|
|
data.CNAME = Convert.ToString(reader["CNAME"]);//中文名称
|
|
|
data.EDICODE = Convert.ToString(reader["EDICODE"]);//中文名称
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);//中文名称
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 品名类型
|
|
|
static public List<sys_template> Getsys_templateList()
|
|
|
{
|
|
|
String strSql = "select GID,[TEMPLATE],[TEMPLATETYPE],[COMPANYID],[TEMPLDATE_DESC] from sys_template where TEMPLATETYPE='发票备注'";
|
|
|
return Setsys_templateData(strSql);
|
|
|
}
|
|
|
private static List<sys_template> Setsys_templateData(String strSql)
|
|
|
{
|
|
|
var headList = new List<sys_template>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
sys_template data = new sys_template();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);//货物代码
|
|
|
data.TEMPLATE = Convert.ToString(reader["TEMPLATE"]);
|
|
|
data.TEMPLATETYPE = Convert.ToString(reader["TEMPLATETYPE"]);
|
|
|
data.COMPANYID = Convert.ToString(reader["COMPANYID"]);
|
|
|
data.TEMPLDATE_DESC = Convert.ToString(reader["TEMPLDATE_DESC"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 品名类型
|
|
|
static public List<CodeGoodsTypeModel> GetCodeGoodsTypeList(string lan)
|
|
|
{
|
|
|
String strSql = "select *,(GoodsTypeCode+'-'+GoodsTypeName) as CodeAndName,(GoodsTypeCode+'-'+ENAME) as CodeAndName2 from Code_GoodsType";
|
|
|
return SetCodeGoodsTypeData(strSql, lan);
|
|
|
}
|
|
|
private static List<CodeGoodsTypeModel> SetCodeGoodsTypeData(String strSql, string lan)
|
|
|
{
|
|
|
var headList = new List<CodeGoodsTypeModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodeGoodsTypeModel data = new CodeGoodsTypeModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);//货物代码
|
|
|
data.GoodsTypeCode = Convert.ToString(reader["GoodsTypeCode"]);
|
|
|
if (lan == "en-us")
|
|
|
{
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName2"]);
|
|
|
data.GoodsTypeName = Convert.ToString(reader["ENAME"]);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
data.GoodsTypeName = Convert.ToString(reader["GoodsTypeName"]);
|
|
|
}
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 箱型
|
|
|
static public List<CodeCtnModel> GetCodeCtnList()
|
|
|
{
|
|
|
String strSql = "select * from [code_ctn] ORDER BY CTNID ";
|
|
|
|
|
|
return SetCodeCtnData(strSql);
|
|
|
}
|
|
|
private static List<CodeCtnModel> SetCodeCtnData(String strSql, bool isempty = true)
|
|
|
{
|
|
|
var headList = new List<CodeCtnModel>();
|
|
|
if (isempty)
|
|
|
{
|
|
|
CodeCtnModel data2 = new CodeCtnModel();
|
|
|
data2.CTN = "";
|
|
|
data2.DLIKGS = 0M;
|
|
|
headList.Add(data2);
|
|
|
}
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodeCtnModel data = new CodeCtnModel();
|
|
|
#region Set DB data to Object
|
|
|
data.CTN = Convert.ToString(reader["CTN"]);
|
|
|
if (reader["DLIKGS"] != DBNull.Value)
|
|
|
data.DLIKGS = Convert.ToDecimal(reader["DLIKGS"]);
|
|
|
if (reader["CTNWEIGHT"] != DBNull.Value)
|
|
|
data.CTNWEIGHT = Convert.ToDecimal(reader["CTNWEIGHT"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<CodeCtnModel> GetCodeCtnList(string condition, bool isempty = true)
|
|
|
{
|
|
|
String strSql = "select * from [code_ctn] ";
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql += " where " + condition;
|
|
|
|
|
|
|
|
|
}
|
|
|
strSql += " ORDER BY CTNID";
|
|
|
|
|
|
return SetCodeCtnData(strSql, isempty);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 集装箱显示
|
|
|
static public CtnDispModel GetCtnDisp()
|
|
|
{
|
|
|
String strSql = "SELECT top 1 * from code_ctn_disp";
|
|
|
return SetCtnDispData(strSql);
|
|
|
}
|
|
|
private static CtnDispModel SetCtnDispData(String strSql)
|
|
|
{
|
|
|
var headList = new CtnDispModel();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CtnDispModel data = new CtnDispModel();
|
|
|
#region Set DB data to Object
|
|
|
data.ID = Convert.ToString(reader["ID"]);
|
|
|
data.CNT1 = Convert.ToString(reader["CNT1"]);
|
|
|
data.CNT2 = Convert.ToString(reader["CNT2"]);
|
|
|
data.CNT3 = Convert.ToString(reader["CNT3"]);
|
|
|
data.CNT4 = Convert.ToString(reader["CNT4"]);
|
|
|
data.CNT5 = Convert.ToString(reader["CNT5"]);
|
|
|
data.CNT6 = Convert.ToString(reader["CNT6"]);
|
|
|
data.CNT7 = Convert.ToString(reader["CNT7"]);
|
|
|
data.CNT8 = Convert.ToString(reader["CNT8"]);
|
|
|
data.CNT9 = Convert.ToString(reader["CNT9"]);
|
|
|
data.CNT10 = Convert.ToString(reader["CNT10"]);
|
|
|
data.CORPID = Convert.ToString(reader["CORPID"]);
|
|
|
#endregion
|
|
|
headList = data;
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 航线
|
|
|
static public List<LaneModel> GetCodeLaneList(string lan)
|
|
|
{
|
|
|
String strSql = "select * from [code_lanes] ORDER BY LANE";
|
|
|
return SetCodeLaneData(strSql, lan);
|
|
|
}
|
|
|
private static List<LaneModel> SetCodeLaneData(String strSql, string lan)
|
|
|
{
|
|
|
var headList = new List<LaneModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
LaneModel data = new LaneModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.LANEID = Convert.ToString(reader["LANEID"]);
|
|
|
if (lan == "en-us")
|
|
|
data.LANE = Convert.ToString(reader["LANEEN"]);
|
|
|
else
|
|
|
data.LANE = Convert.ToString(reader["LANE"]);
|
|
|
data.LANEEN = Convert.ToString(reader["LANEEN"]);
|
|
|
data.EDICODE = Convert.ToString(reader["EDICODE"]);
|
|
|
data.OP = Convert.ToString(reader["OP"]);
|
|
|
data.DOC = Convert.ToString(reader["DOC"]);
|
|
|
data.CUSTSERVICE = Convert.ToString(reader["CUSTSERVICE"]);
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
LaneModel adata = new LaneModel();
|
|
|
#region Set DB data to Object
|
|
|
adata.GID = "";
|
|
|
adata.LANEID = "";
|
|
|
adata.LANE = "";
|
|
|
adata.LANEEN = "";
|
|
|
adata.EDICODE = "";
|
|
|
#endregion
|
|
|
headList.Add(adata);
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 付费方式
|
|
|
static public List<CodeFrtModel> GetCodeFrtList()
|
|
|
{
|
|
|
String strSql = "select * from code_frt ORDER BY FRT";
|
|
|
return SetCodeFrtData(strSql);
|
|
|
}
|
|
|
private static List<CodeFrtModel> SetCodeFrtData(String strSql)
|
|
|
{
|
|
|
var headList = new List<CodeFrtModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodeFrtModel data = new CodeFrtModel();
|
|
|
#region Set DB data to Object
|
|
|
data.FEID = Convert.ToString(reader["FEID"]);
|
|
|
data.FRT = Convert.ToString(reader["FRT"]);
|
|
|
data.FRTCNAME = Convert.ToString(reader["FRTCNAME"]);
|
|
|
data.EDICODE = Convert.ToString(reader["EDICODE"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 签单方式
|
|
|
static public List<CodeBLTYPEModel> GetCodeBLTYPEList(string lan)
|
|
|
{
|
|
|
String strSql = "select * from code_issutype ORDER BY BLTYPE";
|
|
|
return SetCodeBLTYPEData(strSql, lan);
|
|
|
}
|
|
|
private static List<CodeBLTYPEModel> SetCodeBLTYPEData(String strSql, string lan)
|
|
|
{
|
|
|
var headList = new List<CodeBLTYPEModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodeBLTYPEModel data = new CodeBLTYPEModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
if (lan == "en-us")
|
|
|
data.BLTYPE = Convert.ToString(reader["ENAME"]);
|
|
|
else
|
|
|
data.BLTYPE = Convert.ToString(reader["BLTYPE"]);
|
|
|
data.NOBILL = Convert.ToString(reader["NOBILL"]);
|
|
|
data.COPYNOBILL = Convert.ToString(reader["COPYNOBILL"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 运输条款
|
|
|
static public List<CodeSERVICEModel> GetCodeSERVICEList()
|
|
|
{
|
|
|
String strSql = "select * from code_service ORDER BY SERVICE";
|
|
|
return SetCodeSERVICEData(strSql);
|
|
|
}
|
|
|
private static List<CodeSERVICEModel> SetCodeSERVICEData(String strSql)
|
|
|
{
|
|
|
var headList = new List<CodeSERVICEModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodeSERVICEModel data = new CodeSERVICEModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.SERVICE = Convert.ToString(reader["SERVICE"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 提单模板
|
|
|
static public List<CodeTemplateModel> GetCodeTemplateList()
|
|
|
{
|
|
|
String strSql = "select * from code_template ";
|
|
|
return SetCodeTemplateData(strSql);
|
|
|
}
|
|
|
private static List<CodeTemplateModel> SetCodeTemplateData(String strSql)
|
|
|
{
|
|
|
var headList = new List<CodeTemplateModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodeTemplateModel data = new CodeTemplateModel();
|
|
|
#region Set DB data to Object
|
|
|
data.TEMPLATEID = Convert.ToString(reader["TEMPLATEID"]);
|
|
|
data.TEMPLATE = Convert.ToString(reader["TEMPLATE"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 件数包装
|
|
|
static public List<CodePackageModel> GetCodePackageList()
|
|
|
{
|
|
|
String strSql = "select * from [code_package] order by PKGS";
|
|
|
return SetCodePackageData(strSql);
|
|
|
}
|
|
|
private static List<CodePackageModel> SetCodePackageData(String strSql)
|
|
|
{
|
|
|
var headList = new List<CodePackageModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodePackageModel data = new CodePackageModel();
|
|
|
#region Set DB data to Object
|
|
|
data.PKGS = Convert.ToString(reader["PKGS"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 币别
|
|
|
static public List<CodeCurrencyModel> GetCodeCurrencyList(string condition)
|
|
|
{
|
|
|
String strSql = "select * from [code_currency]";
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql += " where " + condition;
|
|
|
}
|
|
|
return SetCodeCurrencyData(strSql);
|
|
|
}
|
|
|
private static List<CodeCurrencyModel> SetCodeCurrencyData(String strSql)
|
|
|
{
|
|
|
var headList = new List<CodeCurrencyModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodeCurrencyModel data = new CodeCurrencyModel();
|
|
|
#region Set DB data to Object
|
|
|
data.CODENAME = Convert.ToString(reader["CODENAME"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 委托单位_联系人
|
|
|
static public List<InfoClientContactModel> GetInfoClientContactList(string condition)
|
|
|
{
|
|
|
String strSql = "select * from [info_client_contact]";
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql += " where " + condition;
|
|
|
}
|
|
|
return SetInfoClientContactData(strSql);
|
|
|
}
|
|
|
private static List<InfoClientContactModel> SetInfoClientContactData(String strSql)
|
|
|
{
|
|
|
var headList = new List<InfoClientContactModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
InfoClientContactModel data = new InfoClientContactModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.SHOWNAME = Convert.ToString(reader["SHOWNAME"]);
|
|
|
data.EMAIL = Convert.ToString(reader["EMAIL"]);
|
|
|
data.TEL = Convert.ToString(reader["TEL"]);
|
|
|
data.FAX = Convert.ToString(reader["FAX"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
var _blank = new InfoClientContactModel();
|
|
|
headList.Add(_blank);
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<InfoClientContactModel> GetInfoClientMailTel(string CUSTOMERNAME)
|
|
|
{
|
|
|
var ContactList = GetInfoClientContactList(" LINKID in(select GID from info_client where shortname='" + CUSTOMERNAME + "') and isnull(email,'')<>'' ");
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(CUSTOMERNAME))
|
|
|
{
|
|
|
var infoclient = MsInfoClientDAL.GetData(" shortname='" + CUSTOMERNAME + "' ");
|
|
|
|
|
|
var _infoclient = new InfoClientContactModel();
|
|
|
_infoclient.SHOWNAME = infoclient.SHORTNAME;
|
|
|
_infoclient.TEL = infoclient.TEL;
|
|
|
_infoclient.EMAIL = infoclient.EMAIL;
|
|
|
if (!string.IsNullOrWhiteSpace(_infoclient.EMAIL))
|
|
|
ContactList.Add(_infoclient);
|
|
|
|
|
|
var _infoclient2 = new InfoClientContactModel();
|
|
|
_infoclient2.SHOWNAME = "注意:下拉选项当中带汉字名字,选中后会使用其后方的邮箱地址(不带汉字);你也可以手动输入邮箱,但这时输入的内容请不要带其他汉字,否则无法正确发送邮件。";
|
|
|
ContactList.Add(_infoclient2);
|
|
|
}
|
|
|
|
|
|
return ContactList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 项目
|
|
|
static public List<CwItemModel> GetCwItemList(string condition, string strUserID)
|
|
|
{
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
String strSql = "SELECT *,(FINANCESOFTCODE+'-'+ITEMNAME) as CodeAndName from cw_item where [STARTGID]='" + strCwSTARTGID + "' and (ISDELETE=0 or ISDELETE is null) order by ITEMCODE,ITEMNAME";
|
|
|
return SetCwItemData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<CwItemModel> SetCwItemData(String strSql)
|
|
|
{
|
|
|
var headList = new List<CwItemModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CwItemModel data = new CwItemModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//唯一编码
|
|
|
data.ITEMCODE = (reader["ITEMCODE"] == null ? "" : Convert.ToString(reader["ITEMCODE"]));//年
|
|
|
data.ITEMNAME = (reader["ITEMNAME"] == null ? "" : Convert.ToString(reader["ITEMNAME"]));//月
|
|
|
data.FINANCESOFTCODE = (reader["FINANCESOFTCODE"] == null ? "" : Convert.ToString(reader["FINANCESOFTCODE"]));//月
|
|
|
data.CORPID = (reader["CORPID"] == null ? "" : Convert.ToString(reader["CORPID"]));//分公司代码
|
|
|
data.ISDELETE = (reader["ISDELETE"] == null ? false : Convert.ToBoolean(reader["ISDELETE"]));//是否删除
|
|
|
data.DELETEUSER = (reader["DELETEUSER"] == null ? "" : Convert.ToString(reader["DELETEUSER"]));//删除人
|
|
|
string kjdE = reader["DELETETIME"].ToString();//删除时间
|
|
|
if (reader["DELETETIME"] != null && reader["DELETETIME"].ToString().Trim().IndexOf("0001") < 0 && reader["DELETETIME"].ToString().Trim().IndexOf("1900") < 0 && reader["DELETETIME"].ToString().Trim() != "")
|
|
|
{
|
|
|
data.DELETETIME = Convert.ToDateTime(reader["DELETETIME"]);//删除时间
|
|
|
}
|
|
|
data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//创建人gid
|
|
|
if (data.CREATETIME != null)
|
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);//创建时间
|
|
|
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//更改操作人gid
|
|
|
if (data.MODIFIEDTIME != null)
|
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//更改操作时间
|
|
|
data.CodeAndName = (reader["CodeAndName"] == null ? "" : Convert.ToString(reader["CodeAndName"]));
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获得总账管理的当前账套GID
|
|
|
static public String GetCwSTARTGID(string strUSERID)
|
|
|
{
|
|
|
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
string strSTARTGID = T_ALL_DA.GetStrSQL("GID", "select top 1 GID from cw_design_startusing WITH(NOLOCK) where (ISDELETE=0 or ISDELETE is null) and ISENABLE=1 and GID=(select top 1 STARTGID from [cw_design_startusing_user] WITH(NOLOCK) where USERGID='" + strUSERID + "')");
|
|
|
return strSTARTGID;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获得总账管理的当前账套名称
|
|
|
static public String GetCwSTARTNAME(string strUSERID)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
string strSTARTNAME = T_ALL_DA.GetStrSQL("STARTNAME", "select top 1 STARTNAME from cw_design_startusing WITH(NOLOCK) where (ISDELETE=0 or ISDELETE is null) and ISENABLE=1 and GID=(select top 1 STARTGID from [cw_design_startusing_user] WITH(NOLOCK) where USERGID='" + strUSERID + "')");
|
|
|
return strSTARTNAME;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获得总账管理的当前账套启用年月
|
|
|
static public String GetCwSTARTMONTH(string strUSERID)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
string strSTARTMONTH = T_ALL_DA.GetStrSQL("STARTMONTH", "select top 1 STARTMONTH from cw_design_startusing WITH(NOLOCK) where (ISDELETE=0 or ISDELETE is null) and ISENABLE=1 and GID=(select top 1 STARTGID from [cw_design_startusing_user] WITH(NOLOCK) where USERGID='" + strUSERID + "') order by STARTMONTH desc");
|
|
|
return strSTARTMONTH;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获得总账管理的当前会计期间
|
|
|
static public String GetCwACCDATE(string strUSERID)
|
|
|
{
|
|
|
string strCwSTARTGID = GetCwSTARTGID(strUSERID);
|
|
|
string strSTARTMONTH = GetCwSTARTMONTH(strUSERID);
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
string strACCDATE = T_ALL_DA.GetStrSQL("ACCDATE", "select isnull((SELECT top 1 SUBSTRING(convert(varchar,dateadd(month,1,(ACCDATE+'-01')),23),1,7) as ACCDATE from cw_carry_over WITH(NOLOCK) where STARTGID='" + strCwSTARTGID + "' ORDER by ACCDATE DESC),'" + strSTARTMONTH + "') as ACCDATE");
|
|
|
return strACCDATE;
|
|
|
}
|
|
|
|
|
|
static public String GetCwACCDATE(string strUSERID, string strCwSTARTGID)
|
|
|
{
|
|
|
string strSTARTMONTH = GetCwSTARTMONTH(strUSERID);
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
string strACCDATE = T_ALL_DA.GetStrSQL("ACCDATE", "select isnull((SELECT top 1 SUBSTRING(convert(varchar,dateadd(month,1,(ACCDATE+'-01')),23),1,7) as ACCDATE from cw_carry_over WITH(NOLOCK) where STARTGID='" + strCwSTARTGID + "' ORDER by ACCDATE DESC),'" + strSTARTMONTH + "') as ACCDATE");
|
|
|
return strACCDATE;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获得出纳管理的当前账套GID
|
|
|
static public String GetCtSTARTGID(string strUSERID)
|
|
|
{
|
|
|
string strCwSTARTGID = GetCwSTARTGID(strUSERID);
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
string strSTARTGID = T_ALL_DA.GetStrSQL("GID", "select GID from ct_design_startusing WITH(NOLOCK) where ISENABLE=1 and (ISDELETE=0 or ISDELETE is null) and STARTGID='" + strCwSTARTGID + "'");
|
|
|
return strSTARTGID;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获得出纳管理的当前会计期间
|
|
|
static public String GetCtACCDATE(string strUSERID)
|
|
|
{
|
|
|
string sCtSTARTGID = GetCtSTARTGID(strUSERID);
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
string strACCDATE = T_ALL_DA.GetStrSQL("ACCDATE", "select isnull((SELECT top 1 SUBSTRING(convert(varchar,dateadd(month,1,(ACCDATE+'-01')),23),1,7) as ACCDATE from ct_carry_over WITH(NOLOCK) where STARTGID='" + sCtSTARTGID + "' and ISCARRY=1 ORDER by STARTGID,ACCDATE DESC),ISNULL((select top 1 STARTMONTH from ct_design_startusing WITH(NOLOCK) where STARTGID='" + sCtSTARTGID + "' and ISENABLE=1 and (ISDELETE=0 or ISDELETE is null) order by STARTMONTH desc),'')) as ACCDATE");
|
|
|
return strACCDATE;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 科目币别表查询
|
|
|
static public List<CwAccitemsCurrencyModel> GetCwAccitemsCurrencyList(string strCondition, string strUserID)
|
|
|
{
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT CURRENCY from cw_accitems_currency where LINKGID in (SELECT GID from cw_accitems_gl where [STARTGID]='" + strCwSTARTGID + "')");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" group by CURRENCY");
|
|
|
strSql.Append(" order by CURRENCY");
|
|
|
return SetMsCwAccitemsCurrencyData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<CwAccitemsCurrencyModel> SetMsCwAccitemsCurrencyData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CwAccitemsCurrencyModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
int k = 0;
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
k++;
|
|
|
CwAccitemsCurrencyModel data = new CwAccitemsCurrencyModel();
|
|
|
#region Set DB data to Object
|
|
|
data.CURRENCY = (reader["CURRENCY"] == null ? "" : Convert.ToString(reader["CURRENCY"]).Trim());//币别
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
//
|
|
|
if (k == 0)
|
|
|
{
|
|
|
CwAccitemsCurrencyModel data = new CwAccitemsCurrencyModel();
|
|
|
#region Set DB data to Object
|
|
|
data.LINKGID = "";//科目GID
|
|
|
data.CURRENCY = "RMB";//币别
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 业务类型
|
|
|
static public List<OPLBModel> GetOPLBList(string condition)
|
|
|
{
|
|
|
String strSql = "SELECT OPLB,OPLBNAME from [v_op_bs]";
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql += " where " + condition;
|
|
|
}
|
|
|
strSql += " GROUP by OPLB,OPLBNAME ORDER BY OPLBNAME";
|
|
|
return SetOPLBData(strSql);
|
|
|
}
|
|
|
private static List<OPLBModel> SetOPLBData(String strSql)
|
|
|
{
|
|
|
var headList = new List<OPLBModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
OPLBModel data = new OPLBModel();
|
|
|
#region Set DB data to Object
|
|
|
data.OPLB = Convert.ToString(reader["OPLB"]);
|
|
|
data.OPLBNAME = Convert.ToString(reader["OPLBNAME"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获取 总账科目信息
|
|
|
static public List<CwAccitemsGlModel> GetCwAccitemsGl(string strCondition, string strUserID)
|
|
|
{
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
string strCwACCDATE = GetCwACCDATE(strUserID);
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select *,ACCID+'-'+ACCNAME AS ACCIDNAME from cw_accitems_gl where [year]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "'");
|
|
|
// strSql.Append("select *,ACCID+'-'+ACCNAME+'('+[YEAR]+')' AS ACCIDNAME from cw_accitems_gl where [STARTGID]='" + strCwSTARTGID + "'");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" ORDER BY ACCID ");
|
|
|
|
|
|
return SetCwAccitemsGl(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<CwAccitemsGlModel> SetCwAccitemsGl(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CwAccitemsGlModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CwAccitemsGlModel data = new CwAccitemsGlModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]).Trim());//唯一编码
|
|
|
data.ACCID = (reader["ACCID"] == null ? "" : Convert.ToString(reader["ACCID"]).Trim());//科目代码
|
|
|
data.ACCNAME = (reader["ACCNAME"] == null ? "" : Convert.ToString(reader["ACCNAME"]).Trim());//科目名称
|
|
|
data.ACCIDNAME = Convert.ToString(reader["ACCIDNAME"]);
|
|
|
data.DETAILED = (reader["DETAILED"] == null ? false : Convert.ToBoolean(reader["DETAILED"]));//是否末级科目(标志)
|
|
|
data.DC = (reader["DC"] == null ? "" : Convert.ToString(reader["DC"]).Trim());//借贷方向
|
|
|
data.ISFCY = (reader["ISFCY"] == null ? false : Convert.ToBoolean(reader["ISFCY"]));//是否核算外币
|
|
|
data.ISDEPTACC = (reader["ISDEPTACC"] == null ? false : Convert.ToBoolean(reader["ISDEPTACC"]));//是否核算部门
|
|
|
data.ISEMPLACC = (reader["ISEMPLACC"] == null ? false : Convert.ToBoolean(reader["ISEMPLACC"]));//是否核算人员
|
|
|
data.ISCORPACC = (reader["ISCORPACC"] == null ? false : Convert.ToBoolean(reader["ISCORPACC"]));//是否算客户门
|
|
|
data.ISITEMACC = (reader["ISITEMACC"] == null ? false : Convert.ToBoolean(reader["ISITEMACC"]));//是否核算项目
|
|
|
data.REMARKS = (reader["REMARKS"] == null ? "" : Convert.ToString(reader["REMARKS"]).Trim());//备注
|
|
|
data.YEAR = (reader["YEAR"] == null ? "" : Convert.ToString(reader["YEAR"]).Trim());//年
|
|
|
data.MONTH = (reader["MONTH"] == null ? "" : Convert.ToString(reader["MONTH"]).Trim());//月
|
|
|
data.PACCGID = (reader["PACCGID"] == null ? "" : Convert.ToString(reader["PACCGID"]).Trim());//父级科目代码
|
|
|
data.ACCATTRIBUTE = (reader["ACCATTRIBUTE"] == null ? "" : Convert.ToString(reader["ACCATTRIBUTE"]).Trim());//科目属性(资产、负债、共同、权益、成本、损益)
|
|
|
data.ISENABLE = (reader["ISENABLE"] == null ? false : Convert.ToBoolean(reader["ISENABLE"]));//是否启用
|
|
|
data.ACCTYPE = (reader["ACCTYPE"] == null ? "" : Convert.ToString(reader["ACCTYPE"]).Trim());
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获取 总账科目信息(包含上级科目)
|
|
|
static public List<CwAccitemsGlModel> GetCwAccitemsGlAll(string strCondition, string strUserID, string CwSTARTGID = "", string CwACCDATE = "")
|
|
|
{
|
|
|
string strCwSTARTGID = CwSTARTGID;
|
|
|
if (strCwSTARTGID == "")
|
|
|
{
|
|
|
strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
}
|
|
|
string strCwACCDATE = CwACCDATE;
|
|
|
if (strCwACCDATE == "")
|
|
|
{
|
|
|
strCwACCDATE = GetCwACCDATE(strUserID, strCwSTARTGID);
|
|
|
}
|
|
|
var pacclist = GetCwAccitemsGlPAll(strCwSTARTGID, strCwACCDATE);
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select *,ACCID+ACCNAME AS ACCIDNAME from cw_accitems_gl where [year]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "'");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
return SetCwAccitemsGlAll(strSql, pacclist);
|
|
|
}
|
|
|
|
|
|
static public CwAccitemsGlModel GetCwAccitems(string accid, List<CwAccitemsGlModel> accitemsGlAll)
|
|
|
{
|
|
|
var accitems = accitemsGlAll.Find(t => t.ACCID == accid);
|
|
|
if (accitems == null) accitems = new CwAccitemsGlModel();
|
|
|
return accitems;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
private static List<CwAccitemsGlModel> SetCwAccitemsGlAll(StringBuilder strSql, List<CwAccitemsGlModel> pacclist)
|
|
|
{
|
|
|
var headList = new List<CwAccitemsGlModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CwAccitemsGlModel data = new CwAccitemsGlModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]).Trim());//唯一编码
|
|
|
data.DETAILED = (reader["DETAILED"] == null ? false : Convert.ToBoolean(reader["DETAILED"]));//是否末级科目(标志)
|
|
|
data.DC = (reader["DC"] == null ? "" : Convert.ToString(reader["DC"]).Trim());//借贷方向
|
|
|
data.ISFCY = (reader["ISFCY"] == null ? false : Convert.ToBoolean(reader["ISFCY"]));//是否核算外币
|
|
|
data.ISDEPTACC = (reader["ISDEPTACC"] == null ? false : Convert.ToBoolean(reader["ISDEPTACC"]));//是否核算部门
|
|
|
data.ISEMPLACC = (reader["ISEMPLACC"] == null ? false : Convert.ToBoolean(reader["ISEMPLACC"]));//是否核算人员
|
|
|
data.ISCORPACC = (reader["ISCORPACC"] == null ? false : Convert.ToBoolean(reader["ISCORPACC"]));//是否算客户门
|
|
|
data.ISITEMACC = (reader["ISITEMACC"] == null ? false : Convert.ToBoolean(reader["ISITEMACC"]));//是否核算项目
|
|
|
data.REMARKS = (reader["REMARKS"] == null ? "" : Convert.ToString(reader["REMARKS"]).Trim());//备注
|
|
|
data.YEAR = (reader["YEAR"] == null ? "" : Convert.ToString(reader["YEAR"]).Trim());//年
|
|
|
data.MONTH = (reader["MONTH"] == null ? "" : Convert.ToString(reader["MONTH"]).Trim());//月
|
|
|
data.ACCATTRIBUTE = (reader["ACCATTRIBUTE"] == null ? "" : Convert.ToString(reader["ACCATTRIBUTE"]).Trim());//科目属性(资产、负债、共同、权益、成本、损益)
|
|
|
data.ISENABLE = (reader["ISENABLE"] == null ? false : Convert.ToBoolean(reader["ISENABLE"]));//是否启用
|
|
|
data.ACCTYPE = (reader["ACCTYPE"] == null ? "" : Convert.ToString(reader["ACCTYPE"]).Trim());
|
|
|
//data.ACCIDNAME = (reader["ACCIDNAME"] == null ? "" : Convert.ToString(reader["ACCIDNAME"]).Trim());//科目名称
|
|
|
//
|
|
|
string sPACCGID = (reader["PACCGID"] == null ? "" : Convert.ToString(reader["PACCGID"]).Trim());//父级科目代码
|
|
|
string sACCID = (reader["ACCID"] == null ? "" : Convert.ToString(reader["ACCID"]).Trim());//科目代码
|
|
|
string sACCNAME = (reader["ACCNAME"] == null ? "" : Convert.ToString(reader["ACCNAME"]).Trim());//科目名称
|
|
|
data.ACCLNAME = sACCNAME;
|
|
|
data.PACCGID = sPACCGID;//父级科目代码
|
|
|
data.ACCID = sACCID;//科目代码
|
|
|
data.ACCNAME = setCAGA(sPACCGID, sACCNAME, pacclist);//科目名称
|
|
|
data.ACCIDNAME = sACCID + "-" + data.ACCNAME;//科目名称
|
|
|
data.ISBANK = (reader["ISBANK"] == null ? false : Convert.ToBoolean(reader["ISBANK"]));//是否银行类科目
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<CwAccitemsGlModel> GetCwAccitemsGlPAll(string strCwSTARTGID, string strCwACCDATE)
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select *,ACCID+ACCNAME AS ACCIDNAME from cw_accitems_gl where [year]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "' AND ISENABLE=1 AND DETAILED<>1");
|
|
|
|
|
|
return SetCwAccitemsGlPAll(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<CwAccitemsGlModel> SetCwAccitemsGlPAll(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CwAccitemsGlModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CwAccitemsGlModel data = new CwAccitemsGlModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]).Trim());//唯一编码
|
|
|
data.DETAILED = (reader["DETAILED"] == null ? false : Convert.ToBoolean(reader["DETAILED"]));//是否末级科目(标志)
|
|
|
data.DC = (reader["DC"] == null ? "" : Convert.ToString(reader["DC"]).Trim());//借贷方向
|
|
|
data.ISFCY = (reader["ISFCY"] == null ? false : Convert.ToBoolean(reader["ISFCY"]));//是否核算外币
|
|
|
data.ISDEPTACC = (reader["ISDEPTACC"] == null ? false : Convert.ToBoolean(reader["ISDEPTACC"]));//是否核算部门
|
|
|
data.ISEMPLACC = (reader["ISEMPLACC"] == null ? false : Convert.ToBoolean(reader["ISEMPLACC"]));//是否核算人员
|
|
|
data.ISCORPACC = (reader["ISCORPACC"] == null ? false : Convert.ToBoolean(reader["ISCORPACC"]));//是否算客户门
|
|
|
data.ISITEMACC = (reader["ISITEMACC"] == null ? false : Convert.ToBoolean(reader["ISITEMACC"]));//是否核算项目
|
|
|
data.REMARKS = (reader["REMARKS"] == null ? "" : Convert.ToString(reader["REMARKS"]).Trim());//备注
|
|
|
data.YEAR = (reader["YEAR"] == null ? "" : Convert.ToString(reader["YEAR"]).Trim());//年
|
|
|
data.MONTH = (reader["MONTH"] == null ? "" : Convert.ToString(reader["MONTH"]).Trim());//月
|
|
|
data.ACCATTRIBUTE = (reader["ACCATTRIBUTE"] == null ? "" : Convert.ToString(reader["ACCATTRIBUTE"]).Trim());//科目属性(资产、负债、共同、权益、成本、损益)
|
|
|
data.ISENABLE = (reader["ISENABLE"] == null ? false : Convert.ToBoolean(reader["ISENABLE"]));//是否启用
|
|
|
data.ACCTYPE = (reader["ACCTYPE"] == null ? "" : Convert.ToString(reader["ACCTYPE"]).Trim());
|
|
|
//data.ACCIDNAME = (reader["ACCIDNAME"] == null ? "" : Convert.ToString(reader["ACCIDNAME"]).Trim());//科目名称
|
|
|
//
|
|
|
string sPACCGID = (reader["PACCGID"] == null ? "" : Convert.ToString(reader["PACCGID"]).Trim());//父级科目代码
|
|
|
string sACCID = (reader["ACCID"] == null ? "" : Convert.ToString(reader["ACCID"]).Trim());//科目代码
|
|
|
string sACCNAME = (reader["ACCNAME"] == null ? "" : Convert.ToString(reader["ACCNAME"]).Trim());//科目名称
|
|
|
data.PACCGID = sPACCGID;//父级科目代码
|
|
|
data.ACCID = sACCID;//科目代码
|
|
|
data.ACCNAME = sACCNAME;//科目名称
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static public String setCAGA(string sPACCGID, string sACCNAME)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
string sSQL = "select *,(ACCNAME+'_" + sACCNAME + "') AS ACCIDNAME from cw_accitems_gl where gid='" + sPACCGID + "'";
|
|
|
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (ds != null)
|
|
|
{
|
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
sPACCGID = ds.Tables[0].Rows[0]["PACCGID"].ToString();
|
|
|
sACCNAME = ds.Tables[0].Rows[0]["ACCIDNAME"].ToString();
|
|
|
if (sPACCGID.Length > 20)
|
|
|
{
|
|
|
sACCNAME = setCAGA(sPACCGID, sACCNAME);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return sACCNAME;
|
|
|
}
|
|
|
static public String setCAGA(string sPACCGID, string sACCNAME, List<CwAccitemsGlModel> pacclist)
|
|
|
{
|
|
|
pacclist.ForEach(i =>
|
|
|
{
|
|
|
if (i.GID == sPACCGID)
|
|
|
|
|
|
{
|
|
|
sPACCGID = i.PACCGID;
|
|
|
sACCNAME = i.ACCNAME + "_" + sACCNAME;
|
|
|
if (sPACCGID.Length > 26)
|
|
|
{
|
|
|
sACCNAME = setCAGA(sPACCGID, sACCNAME, pacclist);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
return sACCNAME;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取 接口科目信息
|
|
|
static public List<CwAccitemsGlModel> GetCwAccitems(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
//strSql.Append("SELECT [GID],[ACCID],[ACCNAME],[DETAILED],[DC],[ISFCY],[ISDEPTACC],[ISEMPLACC],[ISCORPACC],[ISITEMACC],[REMARKS],ACCID+'_'+ACCNAME AS ACCIDNAME FROM ((SELECT [GID],[ACCID],[ACCNAME],[DETAILED],[DC],[ISFCY],[ISDEPTACC],[ISEMPLACC],[ISCORPACC],[ISITEMACC],[REMARKS] FROM cw_accitems where ACCID is not null and ACCID<>'') UNION (SELECT [GID],FINANCESOFTCODE as [ACCID],BANKNAME as [ACCNAME],1 as [DETAILED],'借' as [DC],0 as [ISFCY],0 as [ISDEPTACC],0 as [ISEMPLACC],0 as [ISCORPACC],0 as [ISITEMACC],'' as [REMARKS] FROM sys_bank where FINANCESOFTCODE is not null and FINANCESOFTCODE<>'')) as a where 1=1");
|
|
|
strSql.Append("SELECT [GID],[ACCID],[ACCNAME],[DETAILED],[DC],[ISFCY],[ISDEPTACC],[ISEMPLACC],[ISCORPACC],[ISITEMACC],[REMARKS],ACCID+'_'+ACCNAME AS ACCIDNAME FROM cw_accitems where ACCID is not null and ACCID<>''");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" order by ACCID");
|
|
|
return SetCwAccitems(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<CwAccitemsGlModel> SetCwAccitems(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CwAccitemsGlModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CwAccitemsGlModel data = new CwAccitemsGlModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]).Trim());
|
|
|
data.ACCID = (reader["ACCID"] == null ? "" : Convert.ToString(reader["ACCID"]).Trim());//科目代码
|
|
|
data.ACCNAME = (reader["ACCNAME"] == null ? "" : Convert.ToString(reader["ACCNAME"]).Trim());//科目名称
|
|
|
data.DETAILED = (reader["DETAILED"] == null ? false : Convert.ToBoolean(reader["DETAILED"]));//是否末级科目(标志)
|
|
|
data.DC = (reader["DC"] == null ? "" : Convert.ToString(reader["DC"]).Trim());//借贷方向
|
|
|
data.ISFCY = (reader["ISFCY"] == null ? false : Convert.ToBoolean(reader["ISFCY"]));//是否核算外币
|
|
|
data.ISDEPTACC = (reader["ISDEPTACC"] == null ? false : Convert.ToBoolean(reader["ISDEPTACC"]));//是否核算部门
|
|
|
data.ISEMPLACC = (reader["ISEMPLACC"] == null ? false : Convert.ToBoolean(reader["ISEMPLACC"]));//是否核算人员
|
|
|
data.ISCORPACC = (reader["ISCORPACC"] == null ? false : Convert.ToBoolean(reader["ISCORPACC"]));//是否算客户门
|
|
|
data.ISITEMACC = (reader["ISITEMACC"] == null ? false : Convert.ToBoolean(reader["ISITEMACC"]));//是否核算项目
|
|
|
data.REMARKS = (reader["REMARKS"] == null ? "" : Convert.ToString(reader["REMARKS"]).Trim());//备注
|
|
|
data.ACCIDNAME = (reader["ACCIDNAME"] == null ? "" : Convert.ToString(reader["ACCIDNAME"]).Trim());
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
//
|
|
|
#region 获取指定表内,符合条件的行数量,主要用于防止删除主表
|
|
|
static public int GetExist(string tablename, string condition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("Select count(*) _count from " + tablename);
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" where " + condition);
|
|
|
}
|
|
|
var _count = 0;
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
|
|
|
_count = Convert.ToInt16(reader["_count"]);
|
|
|
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return _count;
|
|
|
}
|
|
|
|
|
|
//fieldname相同 fieldname2不相同(通常用于判断 某单据号相同而GID号不同 以防止不同业务同单据号)
|
|
|
static public int GetExist(string tablename, string fieldname, string value, string fieldname2, string value2)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
var tvalue = value.Trim();
|
|
|
var condition = new StringBuilder();
|
|
|
if (tvalue == "null" || tvalue == "Null" || tvalue == "NULL")
|
|
|
{
|
|
|
condition.Append(" is null ");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition.Append(fieldname + "='" + tvalue + "'");
|
|
|
}
|
|
|
condition.Append(string.Format(" and {0}<>'{1}' ", fieldname2.Trim(), value2.Trim()));
|
|
|
|
|
|
strSql.Append("Select count(*) _count from " + tablename);
|
|
|
|
|
|
strSql.Append(" where " + condition.ToString());
|
|
|
|
|
|
var _count = 0;
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
|
|
|
_count = Convert.ToInt16(reader["_count"]);
|
|
|
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return _count;
|
|
|
}
|
|
|
|
|
|
//返回 某表中 某字段=某值的列 的数量
|
|
|
static public int GetExist(string tablename, string fieldname, string value)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
var tvalue = value.Trim();
|
|
|
var condition = new StringBuilder();
|
|
|
if (tvalue == "null" || tvalue == "Null" || tvalue == "NULL")
|
|
|
{
|
|
|
condition.Append(" is null ");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition.Append(fieldname + "='" + tvalue + "'");
|
|
|
}
|
|
|
|
|
|
strSql.Append("Select count(*) _count from " + tablename);
|
|
|
|
|
|
strSql.Append(" where " + condition.ToString());
|
|
|
|
|
|
var _count = 0;
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
|
|
|
_count = Convert.ToInt16(reader["_count"]);
|
|
|
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return _count;
|
|
|
}
|
|
|
|
|
|
//返回 某表中 某字段=某值 且 某字段=某值... 的列 的数量
|
|
|
static public int GetExist(string tablename, string keyname, string keyvalue, List<string> fieldnamelist, List<string> valuelist)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
if (fieldnamelist.Count != valuelist.Count) return 999;
|
|
|
var condition = new StringBuilder();
|
|
|
|
|
|
var _listcount = 0;
|
|
|
foreach (var fieldname in fieldnamelist)
|
|
|
{
|
|
|
var value = valuelist[_listcount];
|
|
|
var tvalue = value.Trim();
|
|
|
if (condition.ToString() != "") condition.Append(" and ");
|
|
|
if (tvalue == "null" || tvalue == "Null" || tvalue == "NULL")
|
|
|
{
|
|
|
condition.Append(fieldname + " is null ");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition.Append(fieldname + "='" + tvalue + "'");
|
|
|
}
|
|
|
_listcount++;
|
|
|
}
|
|
|
|
|
|
strSql.Append("Select count(*) _count from " + tablename);
|
|
|
|
|
|
strSql.Append(" where " + keyname + "<>'" + keyvalue + "' and " + condition.ToString());
|
|
|
|
|
|
var _count = 0;
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
|
|
|
_count = Convert.ToInt16(reader["_count"]);
|
|
|
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return _count;
|
|
|
}
|
|
|
|
|
|
static public bool HaveExist(string tablename, string fieldname, string value)
|
|
|
{
|
|
|
var _count = GetExist(tablename, fieldname, value);
|
|
|
|
|
|
bool r = false;
|
|
|
|
|
|
if (_count > 0)
|
|
|
{
|
|
|
r = true;
|
|
|
}
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
static public bool HaveExist(string tablename, string fieldname, string value, string fieldname2, decimal value2)
|
|
|
{
|
|
|
return HaveExist(tablename, fieldname, value, fieldname2, value2.ToString());
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// fieldname相同 fieldname2不相同
|
|
|
/// </summary>
|
|
|
/// <param name="tablename"></param>
|
|
|
/// <param name="fieldname"></param>
|
|
|
/// <param name="value"></param>
|
|
|
/// <param name="fieldname2"></param>
|
|
|
/// <param name="value2"></param>
|
|
|
/// <returns></returns>
|
|
|
static public bool HaveExist(string tablename, string fieldname, string value, string fieldname2, string value2)
|
|
|
{
|
|
|
var _count = GetExist(tablename, fieldname, value, fieldname2, value2);
|
|
|
|
|
|
bool r = false;
|
|
|
|
|
|
if (_count > 0)
|
|
|
{
|
|
|
r = true;
|
|
|
}
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
static public bool HaveExist(string tablename, string condition)
|
|
|
{
|
|
|
var _count = GetExist(tablename, condition);
|
|
|
|
|
|
bool r = false;
|
|
|
|
|
|
if (_count > 0)
|
|
|
{
|
|
|
r = true;
|
|
|
}
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获取 出纳摘要信息
|
|
|
static public List<MsCtExplanDetail> GetEXPLAN(string strCondition, string strUserID)
|
|
|
{
|
|
|
string strCtSTARTGID = BasicDataRefDAL.GetCtSTARTGID(strUserID);
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT *,MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=ct_explan_detail.MODIFIEDUSER) from ct_explan_detail where 1=1");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and LINKGID in (select GID from ct_explan where STARTGID='" + strCtSTARTGID + "' and " + strCondition + ")");
|
|
|
}
|
|
|
strSql.Append(" order by EXPLAN");
|
|
|
return SetEXPLAN(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<MsCtExplanDetail> SetEXPLAN(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsCtExplanDetail>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsCtExplanDetail data = new MsCtExplanDetail();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//唯一编码
|
|
|
data.LINKGID = (reader["LINKGID"] == null ? "" : Convert.ToString(reader["LINKGID"]));//摘要GID
|
|
|
data.EXPLAN = (reader["EXPLAN"] == null ? "" : Convert.ToString(reader["EXPLAN"]));//内容
|
|
|
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//更改操作人gid
|
|
|
if (data.MODIFIEDTIME != null)
|
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//更改操作时间
|
|
|
data.MODIFIEDUSERNAME = (reader["MODIFIEDUSERNAME"] == null ? "" : Convert.ToString(reader["MODIFIEDUSERNAME"]));//更改人
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 通用查询方法 参数是查询语句,必须把GID和值as成GID和GValue
|
|
|
|
|
|
static public List<GeneralModel> GeneralSelect(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(strCondition);
|
|
|
return SetGeneralSelect(strSql);
|
|
|
}
|
|
|
static public List<GeneralModel> GeneralSelect(string tablename, string keyname, string valuename, string condition)
|
|
|
{//keyname=GVALUE一般用于displayname
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(string.Format("select {1} as GID,{2} as GVALUE from {0}", tablename, keyname, valuename));
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" where " + condition);
|
|
|
}
|
|
|
return SetGeneralSelect(strSql);
|
|
|
}
|
|
|
|
|
|
static public List<GeneralModel> GeneralSelect2(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(strCondition);
|
|
|
return SetGeneralSelect3(strSql);
|
|
|
}
|
|
|
|
|
|
#region 将GVALUE的值集合成逗号隔开的
|
|
|
static public List<GeneralModel> GeneralSelect_commaList(string tablename, string valuename, string condition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(string.Format("select distinct {1} as GVALUE from {0}", tablename, valuename));
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" where " + condition);
|
|
|
}
|
|
|
return SetGeneralSelect2(strSql);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获取指定表中,符合条件的字段值,返回一个用逗号隔开各个字段的string
|
|
|
/// <summary>
|
|
|
/// 获取指定表中,符合条件的字段值,返回一个用逗号隔开各个字段的string
|
|
|
/// </summary>
|
|
|
/// <param name="tablename"></param>
|
|
|
/// <param name="valuename"></param>
|
|
|
/// <param name="condition"></param>
|
|
|
/// <returns></returns>
|
|
|
static public string GeneralSelect_commaString(string tablename, string valuename, string condition)
|
|
|
{
|
|
|
var itemlist = GeneralSelect_commaList(tablename, valuename, condition);
|
|
|
var result = "";
|
|
|
if (itemlist.Count > 0)
|
|
|
{
|
|
|
foreach (var item in itemlist)
|
|
|
{
|
|
|
|
|
|
if (result != "")
|
|
|
{
|
|
|
result += ",";
|
|
|
}
|
|
|
result += "'" + item.GVALUE + "'";
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
else return "";
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
public static List<GeneralModel> GeneralGet(string tablename, string condition = "")
|
|
|
{
|
|
|
var _condition = condition;
|
|
|
if (tablename == "company" || tablename == "sys_company")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(_condition))
|
|
|
{
|
|
|
_condition += " and ISDELETED=0 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_condition += " ISDELETED=0 ";
|
|
|
}
|
|
|
return GeneralSelect("company", "GID", "NAME", _condition);
|
|
|
}
|
|
|
else if (tablename == "client")
|
|
|
{
|
|
|
return GeneralSelect("info_client", "GID", "SHORTNAME", _condition);
|
|
|
}
|
|
|
else if (tablename == "client_airline")
|
|
|
{
|
|
|
return GeneralSelect("info_client", "CODENAME", "SHORTNAME", " ISAIRLINES=1 ");
|
|
|
}
|
|
|
return new List<GeneralModel>();
|
|
|
}
|
|
|
|
|
|
public static string GeneralGet_String(string tablename, string condition = "")
|
|
|
{
|
|
|
var idlist = BasicDataRefDAL.GeneralGet(tablename, condition);
|
|
|
var result = "";
|
|
|
if (idlist.Count > 0)
|
|
|
{
|
|
|
result = idlist[0].GVALUE.ToString();
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
private static List<GeneralModel> SetGeneralSelect(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<GeneralModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
GeneralModel data = new GeneralModel();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));
|
|
|
data.GVALUE = (reader["GVALUE"] == null ? "" : Convert.ToString(reader["GVALUE"]));
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
private static List<GeneralModel> SetGeneralSelect2(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<GeneralModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
GeneralModel data = new GeneralModel();
|
|
|
#region Set DB data to Object
|
|
|
|
|
|
data.GVALUE = (reader["GVALUE"] == null ? "" : Convert.ToString(reader["GVALUE"]));
|
|
|
#endregion
|
|
|
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
private static List<GeneralModel> SetGeneralSelect3(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<GeneralModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
GeneralModel data = new GeneralModel();
|
|
|
#region Set DB data to Object
|
|
|
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));
|
|
|
data.GVALUE = (reader["GVALUE"] == null ? "" : Convert.ToString(reader["GVALUE"]));
|
|
|
data.GVALUE2 = (reader["GVALUE2"] == null ? "" : Convert.ToString(reader["GVALUE2"]));
|
|
|
#endregion
|
|
|
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
|
|
|
#region 获取指定表内的某列数据前50行,指定查询条件和排序方式 主要用于提供“近期数据”内容的combox
|
|
|
|
|
|
public static List<GeneralModel> GeneralSelect_Top(string TABLENAME, string FIELDNAME, string condition, string topnum = "50")
|
|
|
{
|
|
|
var result = new List<GeneralModel>();
|
|
|
var sqlstr = "select TOP " + topnum + " " + FIELDNAME + " as GID," + FIELDNAME + " as GVALUE from " + TABLENAME + " where " + condition;
|
|
|
result = GeneralSelect(sqlstr);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获取指定表内的,指定查询条件的,某字段distinct值
|
|
|
|
|
|
public static List<GeneralModel> GeneralSelect_Distinct(string TABLENAME, string FIELDNAME, string condition)
|
|
|
{
|
|
|
var result = new List<GeneralModel>();
|
|
|
var sqlstr = "select distinct " + FIELDNAME + " as GID," + FIELDNAME + " as GVALUE from " + TABLENAME + " where " + condition;
|
|
|
result = GeneralSelect(sqlstr);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 将带逗号的内容拆成单个,并将出现频率最高的放置在最前。参数为(表名 列名 查询条件)
|
|
|
/// <summary>
|
|
|
/// 将带逗号的内容拆成单个,并将出现频率最高的放置在最前。参数为(表名 列名 查询条件)
|
|
|
/// </summary>
|
|
|
/// <param name="tablename"></param>
|
|
|
/// <param name="columnname"></param>
|
|
|
/// <param name="condition"></param>
|
|
|
/// <returns></returns>
|
|
|
static public List<DICModel> GetCommaWord(string tablename, string columnname, string condition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
var column = " case isnull(" + columnname + ",'') when '' then '' else " + columnname + "+',' end ";
|
|
|
strSql.Append(" WITH TB_2 AS ( ");
|
|
|
strSql.Append(" SELECT " + column + " as " + columnname + " ,CHARINDEX(','," + column + ") STA,CHARINDEX(','," + column + ")-1 LENS FROM " + tablename + " where 1=1 ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" and " + condition);
|
|
|
}
|
|
|
strSql.Append(" UNION ALL ");
|
|
|
strSql.Append(" SELECT " + columnname + " ,CHARINDEX(','," + columnname + ",STA+1) STA,CHARINDEX(','," + columnname + ",STA+1)-STA-1 LENS FROM TB_2 WHERE STA<>0) ");
|
|
|
strSql.Append(" SELECT distinct SUBSTRING(" + columnname + ",STA-LENS,LENS) VALUE,count(SUBSTRING(" + columnname + ",STA-LENS,LENS)) count FROM TB_2 ");
|
|
|
strSql.Append(" WHERE STA<>0 ");
|
|
|
strSql.Append(" group by SUBSTRING(" + columnname + ",STA-LENS,LENS) ");
|
|
|
strSql.Append(" order by count(SUBSTRING(" + columnname + ",STA-LENS,LENS)) DESC ");
|
|
|
|
|
|
return SetCommaWord(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<DICModel> SetCommaWord(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<DICModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
DICModel data = new DICModel();
|
|
|
#region Set DB data to Object
|
|
|
data.KEYFIELD = (reader["VALUE"] == null ? "" : Convert.ToString(reader["VALUE"]));//惟一值
|
|
|
data.VALUEFIELD = (reader["count"] == null ? "" : Convert.ToString(reader["count"]));//惟一值
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
|
|
|
#region 空白项
|
|
|
DICModel data2 = new DICModel();
|
|
|
data2.KEYFIELD = "";//惟一值
|
|
|
data2.VALUEFIELD = "0";//惟一值
|
|
|
#endregion
|
|
|
headList.Add(data2);
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
//符合条件的表、字段中,实际已存在的用逗号隔开的部分,是否包含指定文字;
|
|
|
/// <summary>
|
|
|
/// 符合条件的表、字段中,实际已存在的用逗号隔开的部分,是否包含指定文字;
|
|
|
/// </summary>
|
|
|
/// <param name="tablename"></param>
|
|
|
/// <param name="columnname"></param>
|
|
|
/// <param name="ExistValue"></param>
|
|
|
/// <param name="condition"></param>
|
|
|
/// <returns></returns>
|
|
|
static public bool GetCommaWordExist(string tablename, string columnname, string ExistValue, string condition)
|
|
|
{
|
|
|
var _list = GetCommaWord(tablename, columnname, condition);
|
|
|
if (_list.Count() == 0)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
foreach (var item in _list)
|
|
|
{
|
|
|
if (item.KEYFIELD == ExistValue.Trim())
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 将逗号隔开的字符串 转化成:1 string[];2:用于sql的带单引号string;3:一个stringList 并按字母顺序排序
|
|
|
|
|
|
public static string[] getStringArray(string str, char splitword = ',')
|
|
|
{
|
|
|
var stringlist = str.Split(splitword);
|
|
|
return stringlist;
|
|
|
}
|
|
|
public static string getSqlString(string str, char splitword = ',')
|
|
|
{
|
|
|
var stringlist = str.Split(splitword);
|
|
|
|
|
|
var result = "";
|
|
|
foreach (var item in stringlist)
|
|
|
{
|
|
|
if (result != "") result += ",";
|
|
|
result += "'" + item + "'";
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public static List<string> getStrListfromCommaStr(string str, char splitword = ',')
|
|
|
{
|
|
|
var stringlist = str.Split(splitword).ToList<string>();
|
|
|
|
|
|
stringlist.OrderBy(o => o.ToString());
|
|
|
|
|
|
return stringlist;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 判断字符串中是否包含中文
|
|
|
/// <summary>
|
|
|
/// 判断字符串中是否包含中文
|
|
|
/// </summary>
|
|
|
/// <param name="str">需要判断的字符串</param>
|
|
|
/// <returns>判断结果</returns>
|
|
|
public static bool isHasChinese(string str)
|
|
|
{
|
|
|
return System.Text.RegularExpressions.Regex.IsMatch(str, @"[\u4e00-\u9fa5]");
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 直接DelCtnDetailList执行sql命令(小心使用)
|
|
|
static public int ExecSql(string StrSql)
|
|
|
{
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
var _count = -1;
|
|
|
try
|
|
|
{
|
|
|
_count = db.ExecuteNonQuery(CommandType.Text, StrSql);
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
return _count;
|
|
|
}
|
|
|
|
|
|
return _count;
|
|
|
}
|
|
|
|
|
|
static public int ExecSql_DB(string StrSql, string DBNAME = "")
|
|
|
{
|
|
|
Database db = DatabaseFactory.CreateDatabase(DBNAME);
|
|
|
var _count = db.ExecuteNonQuery(CommandType.Text, StrSql);
|
|
|
|
|
|
return _count;
|
|
|
}
|
|
|
|
|
|
static public int ExecSql(SqlCommand StrSqlComm)
|
|
|
{
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
var _count = db.ExecuteNonQuery(StrSqlComm);
|
|
|
|
|
|
return _count;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 返回实体类的属性名与列表
|
|
|
public static List<FieldModel> getProperties<T>(T t)
|
|
|
{
|
|
|
var tStr = new List<FieldModel>();
|
|
|
if (t == null)
|
|
|
{
|
|
|
return tStr;
|
|
|
}
|
|
|
System.Reflection.PropertyInfo[] properties = t.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
|
|
|
|
|
|
if (properties.Length <= 0)
|
|
|
{
|
|
|
return tStr;
|
|
|
}
|
|
|
foreach (System.Reflection.PropertyInfo item in properties)
|
|
|
{
|
|
|
string name = item.Name;
|
|
|
object value = item.GetValue(t, null);
|
|
|
if (item.PropertyType.IsValueType || item.PropertyType.Name.StartsWith("String"))
|
|
|
{
|
|
|
var _sl = new FieldModel();
|
|
|
_sl.FieldName = name;
|
|
|
if (value != null)
|
|
|
{
|
|
|
_sl.FieldValue = value.ToString();
|
|
|
}
|
|
|
tStr.Add(_sl);
|
|
|
//tStr += string.Format("{0}:{1},", name, value);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//getProperties(value);
|
|
|
}
|
|
|
}
|
|
|
return tStr;
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取 InfoClass管理分类表
|
|
|
static public List<MsInfoClassEntity> GetMsInfoClass(string strCondition, string strUserID)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select * from InfoClass where 1=1");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" order by sortID");
|
|
|
return SetMsInfoClass(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<MsInfoClassEntity> SetMsInfoClass(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsInfoClassEntity>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsInfoClassEntity data = new MsInfoClassEntity();
|
|
|
#region Set DB data to Object
|
|
|
data.ID = (reader["ID"] == null ? 0 : Convert.ToInt32(reader["ID"]));
|
|
|
data.PARENTID = (reader["PARENTID"] == null ? "" : Convert.ToString(reader["PARENTID"]));
|
|
|
data.CLASSID = (reader["CLASSID"] == null ? "" : Convert.ToString(reader["CLASSID"]));
|
|
|
data.CLASSNAMEENG = (reader["CLASSNAMEENG"] == null ? "" : Convert.ToString(reader["CLASSNAMEENG"]));
|
|
|
data.CLASSNAME = (reader["CLASSNAME"] == null ? "" : Convert.ToString(reader["CLASSNAME"]));
|
|
|
data.CLASSICON = (reader["CLASSICON"] == null ? "" : Convert.ToString(reader["CLASSICON"]));
|
|
|
data.CLASSKEY = (reader["CLASSKEY"] == null ? "" : Convert.ToString(reader["CLASSKEY"]));
|
|
|
data.CLASSLOCATION = (reader["CLASSLOCATION"] == null ? 0 : Convert.ToInt32(reader["CLASSLOCATION"]));
|
|
|
data.CLASSATTRIB = (reader["CLASSATTRIB"] == null ? 0 : Convert.ToInt32(reader["CLASSATTRIB"]));
|
|
|
data.HASCHILD = (reader["HASCHILD"] == null ? false : Convert.ToBoolean(reader["HASCHILD"]));
|
|
|
data.ISUSED = (reader["ISUSED"] == null ? false : Convert.ToBoolean(reader["ISUSED"]));
|
|
|
data.ISSORT = (reader["ISSORT"] == null ? false : Convert.ToBoolean(reader["ISSORT"]));
|
|
|
data.SORTATTRIB = (reader["SORTATTRIB"] == null ? false : Convert.ToBoolean(reader["SORTATTRIB"]));
|
|
|
data.SORTID = (reader["SORTID"] == null ? 0 : Convert.ToInt32(reader["SORTID"]));
|
|
|
data.AUTHOR = (reader["AUTHOR"] == null ? "" : Convert.ToString(reader["AUTHOR"]));
|
|
|
data.CREATEDATE = Convert.ToDateTime(reader["CREATEDATE"]);
|
|
|
data.LASTMODIFYDATE = Convert.ToDateTime(reader["LASTMODIFYDATE"]);
|
|
|
data.DEL_SIGN = (reader["DEL_SIGN"] == null ? false : Convert.ToBoolean(reader["DEL_SIGN"]));
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
|
|
|
#region 空白项
|
|
|
MsInfoClassEntity data2 = new MsInfoClassEntity();
|
|
|
data2.ID = 0;
|
|
|
data2.PARENTID = "";
|
|
|
data2.CLASSID = "";
|
|
|
data2.CLASSNAMEENG = "";
|
|
|
data2.CLASSNAME = "";
|
|
|
data2.CLASSICON = "";
|
|
|
data2.CLASSKEY = "";
|
|
|
data2.CLASSLOCATION = 0;
|
|
|
data2.CLASSATTRIB = 0;
|
|
|
data2.HASCHILD = false;
|
|
|
data2.ISUSED = false;
|
|
|
data2.ISSORT = false;
|
|
|
data2.SORTATTRIB = false;
|
|
|
data2.SORTID = 0;
|
|
|
data2.AUTHOR = "";
|
|
|
data2.CREATEDATE = DateTime.Now;
|
|
|
data2.LASTMODIFYDATE = DateTime.Now;
|
|
|
data2.DEL_SIGN = false;
|
|
|
#endregion
|
|
|
headList.Add(data2);
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获取 客户子项目
|
|
|
static public List<MsInfoClientItemEntity> GetMsInfoClientItem(string strCondition, string strUserID)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select * from info_client_item where 1=1");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
return SetMsInfoClientItem(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<MsInfoClientItemEntity> SetMsInfoClientItem(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsInfoClientItemEntity>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsInfoClientItemEntity data = new MsInfoClientItemEntity();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//惟一值
|
|
|
data.LINKGID = (reader["LINKGID"] == null ? "" : Convert.ToString(reader["LINKGID"]));//客户GID
|
|
|
data.ITEMNAME = (reader["ITEMNAME"] == null ? "" : Convert.ToString(reader["ITEMNAME"]));//项目名称
|
|
|
data.STARTTIME = Convert.ToDateTime(reader["STARTTIME"]);//起始时间
|
|
|
data.ENDTIME = Convert.ToDateTime(reader["ENDTIME"]);//结束时间
|
|
|
data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//创建人gid
|
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);//创建时间
|
|
|
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//更改操作人gid
|
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//最后一次更改时间
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
|
|
|
#region 空白项
|
|
|
MsInfoClientItemEntity data2 = new MsInfoClientItemEntity();
|
|
|
data2.GID = "";//惟一值
|
|
|
data2.LINKGID = "";//客户GID
|
|
|
data2.ITEMNAME = "";//项目名称
|
|
|
data2.STARTTIME = DateTime.Now;//起始时间
|
|
|
data2.ENDTIME = DateTime.Now;//结束时间
|
|
|
data2.CREATEUSER = "";//创建人gid
|
|
|
data2.CREATETIME = DateTime.Now;//创建时间
|
|
|
data2.MODIFIEDUSER = "";//更改操作人gid
|
|
|
data2.MODIFIEDTIME = DateTime.Now;//最后一次更改时间
|
|
|
#endregion
|
|
|
headList.Add(data2);
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 良通捷运 目的地列表
|
|
|
static public List<DICModel> GetDetiNation_LTJY(string strCondition, string strUserID)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select DISTINCT NAME,DISTANCE from PC_LTJY_Distance where 1=1 ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
return SetDetiNation_LTJY(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<DICModel> SetDetiNation_LTJY(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<DICModel>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
DICModel data = new DICModel();
|
|
|
#region Set DB data to Object
|
|
|
data.KEYFIELD = (reader["NAME"] == null ? "" : Convert.ToString(reader["NAME"]));//惟一值
|
|
|
data.VALUEFIELD = (reader["DISTANCE"] == null ? "" : Convert.ToString(reader["DISTANCE"]));//惟一值
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
|
|
|
#region 空白项
|
|
|
DICModel data2 = new DICModel();
|
|
|
data2.KEYFIELD = "";//惟一值
|
|
|
data2.VALUEFIELD = "0";//惟一值
|
|
|
#endregion
|
|
|
headList.Add(data2);
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 国家
|
|
|
static public List<CangDanCountry> GetCountryList(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select distinct c_country_code+'-'+c_country_name as CodeAndName,c_country_code CountryCode,c_country_name CountryName,c_country_ename CountryNameEn from t_sys_country_code where 1=1");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
return SetCountryData(strSql.ToString());
|
|
|
}
|
|
|
|
|
|
private static List<CangDanCountry> SetCountryData(string sql)
|
|
|
{
|
|
|
var headList = new List<CangDanCountry>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CangDanCountry data = new CangDanCountry();
|
|
|
#region Set DB data to Object
|
|
|
data.CountryName = Convert.ToString(reader["CountryName"]);
|
|
|
data.CountryNameEn = Convert.ToString(reader["CountryNameEn"]);
|
|
|
data.CountryCode = Convert.ToString(reader["CountryCode"]);
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 逻辑信息子表操作
|
|
|
|
|
|
#region 将一个dictionary转化为用;;和::隔开的文本
|
|
|
public static string DicToStr(Dictionary<string, string> dic)
|
|
|
{
|
|
|
var result = "";
|
|
|
if (dic != null)
|
|
|
{
|
|
|
foreach (var item in dic)
|
|
|
{
|
|
|
result += item.Key + "::" + item.Value + ";;";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 将一个用;;和::隔开的文本转化为dictionary
|
|
|
public static Dictionary<string, string> StrToDic(string dicstr)
|
|
|
{
|
|
|
var result = new Dictionary<string, string>();
|
|
|
|
|
|
var list = Regex.Split(dicstr, ";;").ToList();
|
|
|
|
|
|
foreach (var item in list)
|
|
|
{
|
|
|
var itemarray = Regex.Split(item, "::");
|
|
|
if (itemarray.Length < 2) continue;
|
|
|
result.Add(itemarray[0], itemarray[1] == null ? "" : itemarray[1]);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
public static Dictionary<string, string> GetLogicInfo(string BSNO, string PROPNAME)
|
|
|
{
|
|
|
|
|
|
CommonDataContext cdc = new CommonDataContext();
|
|
|
|
|
|
var result = new Dictionary<string, string>();
|
|
|
|
|
|
var infoList = cdc.OP_LOGICINFO.Where(x => x.BSNO == BSNO && x.PROPNAME == PROPNAME).ToList();
|
|
|
|
|
|
if (infoList != null && infoList.Count > 0)
|
|
|
{
|
|
|
result = StrToDic(infoList[0].PROPVALUE);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static void SaveLogicInfo(string BSNO, string PROPNAME, Dictionary<string, string> InfoDic = null)
|
|
|
{
|
|
|
|
|
|
CommonDataContext cdc = new CommonDataContext();
|
|
|
|
|
|
var result = new Dictionary<string, string>();
|
|
|
|
|
|
var infoList = cdc.OP_LOGICINFO.Where(x => x.BSNO == BSNO && x.PROPNAME == PROPNAME).ToList();
|
|
|
|
|
|
if (infoList != null && infoList.Count > 0)
|
|
|
{
|
|
|
|
|
|
var updrec = infoList[0];
|
|
|
updrec.PROPVALUE = DicToStr(InfoDic);
|
|
|
cdc.OP_LOGICINFO.AddOrUpdate(updrec);
|
|
|
cdc.SaveChanges();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var newinfo = new OP_LOGICINFO_md();
|
|
|
newinfo.GID = Guid.NewGuid();
|
|
|
newinfo.BSNO = BSNO;
|
|
|
newinfo.PROPNAME = PROPNAME;
|
|
|
newinfo.PROPVALUE = DicToStr(InfoDic);
|
|
|
cdc.OP_LOGICINFO.Add(newinfo);
|
|
|
cdc.SaveChanges();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static Dictionary<string, string> GetLogicHaveValue(string PROPNAME, string fieldname, string fieldvalue)
|
|
|
{
|
|
|
|
|
|
CommonDataContext cdc = new CommonDataContext();
|
|
|
|
|
|
var result = new Dictionary<string, string>();
|
|
|
|
|
|
var infoList = cdc.OP_LOGICINFO.Where(x => x.PROPNAME == PROPNAME && x.PROPVALUE.Contains(fieldname) && x.PROPVALUE.Contains(fieldvalue)).ToList();
|
|
|
|
|
|
if (infoList != null && infoList.Count > 0)
|
|
|
{
|
|
|
foreach (var item in infoList) {
|
|
|
var lv = StrToDic(infoList[0].PROPVALUE);
|
|
|
if (lv[fieldname] == fieldvalue) {
|
|
|
result = lv;
|
|
|
result.Add("BSNO", item.BSNO);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
public static string GetLogicValue(string PROPNAME, string fieldname, string bsno)
|
|
|
{
|
|
|
|
|
|
CommonDataContext cdc = new CommonDataContext();
|
|
|
|
|
|
var result = "";
|
|
|
|
|
|
var infoList = cdc.OP_LOGICINFO.Where(x => x.PROPNAME == PROPNAME && x.BSNO == bsno).ToList();
|
|
|
|
|
|
if (infoList != null && infoList.Count > 0)
|
|
|
{
|
|
|
foreach (var item in infoList)
|
|
|
{
|
|
|
var lv = StrToDic(infoList[0].PROPVALUE);
|
|
|
result = lv[fieldname];
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region SaveLog
|
|
|
public static ContentResult SaveLog(List<FieldModel> data, string USERID, string NAME, string LOGTYPE)
|
|
|
{
|
|
|
var headData = new Sys_Logmd();//JsonConvert.Deserialize<WorkLogmb>(data);
|
|
|
|
|
|
headData.GID = System.Guid.NewGuid().ToString();
|
|
|
headData.NAME = NAME;
|
|
|
headData.LOGTYPE = LOGTYPE;
|
|
|
headData.LOGTIME = System.DateTime.Now;
|
|
|
headData.CREATEUSER = USERID;
|
|
|
headData.LOGCONTENT = "";
|
|
|
|
|
|
foreach (var _F in data)
|
|
|
{
|
|
|
headData.LOGCONTENT += string.Format("{0}:{1},", _F.FieldName, _F.FieldValue);
|
|
|
}
|
|
|
|
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
|
headData.ModelUIStatus = "I";
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
var modb = new ModelObjectRepository();
|
|
|
result = modb.Save(headData);
|
|
|
|
|
|
//刷新父窗口上的父节点
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
public static ContentResult SaveLog<T>(T t, string USERID, string NAME, string LOGTYPE)
|
|
|
{
|
|
|
var _FieldList = getProperties(t);
|
|
|
return SaveLog(_FieldList, USERID, NAME, LOGTYPE);
|
|
|
}
|
|
|
|
|
|
public static ContentResult SaveLog<T>(List<T> t, string USERID, string NAME, string LOGTYPE)
|
|
|
{
|
|
|
var _r = new ContentResult();
|
|
|
foreach (var item in t)
|
|
|
{
|
|
|
var _FieldList = getProperties(item);
|
|
|
_r = SaveLog(_FieldList, USERID, NAME, LOGTYPE);
|
|
|
}
|
|
|
return _r;
|
|
|
}
|
|
|
|
|
|
public static ContentResult SaveLog(string data, string USERID, string NAME, string LOGTYPE)
|
|
|
{
|
|
|
var headData = new Sys_Logmd();//JsonConvert.Deserialize<WorkLogmb>(data);
|
|
|
|
|
|
headData.GID = System.Guid.NewGuid().ToString();
|
|
|
headData.NAME = NAME;
|
|
|
headData.LOGTYPE = LOGTYPE;
|
|
|
headData.LOGTIME = System.DateTime.Now;
|
|
|
headData.CREATEUSER = USERID;
|
|
|
//headData.LOGCONTENT = "";
|
|
|
|
|
|
|
|
|
headData.LOGCONTENT = data;
|
|
|
|
|
|
|
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
|
headData.ModelUIStatus = "I";
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
var modb = new ModelObjectRepository();
|
|
|
result = modb.Save(headData);
|
|
|
|
|
|
//刷新父窗口上的父节点
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
Data = headData.GID
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
public class LoggerHelper {
|
|
|
private string _name { get; set; }
|
|
|
|
|
|
public LoggerHelper() { }
|
|
|
|
|
|
public LoggerHelper(string NAME) { _name = NAME; }
|
|
|
|
|
|
public void Save(string data, string LOGTYPE="", string USERID="") {
|
|
|
SaveLog(data, USERID, _name, LOGTYPE);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 读取指定文件 然后将其写入指定表的指定字段(image字段)
|
|
|
|
|
|
public static DBResult SaveFileIntoDB(FileUrlModel FileInfo, string filename)
|
|
|
{
|
|
|
DBResult _r = new DBResult();
|
|
|
_r.Success = false;
|
|
|
var _filename = HttpContext.Current.Server.MapPath(filename);
|
|
|
|
|
|
if (File.Exists(_filename))
|
|
|
{
|
|
|
//var file = File.Open(filename, FileMode.Open);
|
|
|
|
|
|
byte[] bytes = File.ReadAllBytes(_filename);
|
|
|
|
|
|
SqlCommand cmd = new SqlCommand(string.Format("update {0} set {1} =@image where {2}='{3}'", FileInfo.TableName, FileInfo.ImgName, FileInfo.KeyName, FileInfo.KeyValue));
|
|
|
|
|
|
cmd.Parameters.Add("@image", SqlDbType.Image).Value = bytes;
|
|
|
|
|
|
var _c = ExecSql(cmd);
|
|
|
|
|
|
if (_c > 0)
|
|
|
{
|
|
|
_r.Success = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
}
|
|
|
return _r;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_r.Message = "不存在指定文件";
|
|
|
return _r;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static DBResult DelFileFromDB(FileUrlModel FileInfo)
|
|
|
{
|
|
|
DBResult _r = new DBResult();
|
|
|
_r.Success = false;
|
|
|
|
|
|
byte[] bytes = new byte[0];
|
|
|
|
|
|
SqlCommand cmd = new SqlCommand(string.Format("update {0} set {1} =@image where {2}='{3}'", FileInfo.TableName, FileInfo.ImgName, FileInfo.KeyName, FileInfo.KeyValue));
|
|
|
|
|
|
cmd.Parameters.Add("@image", SqlDbType.Image).Value = bytes;
|
|
|
|
|
|
var _c = ExecSql(cmd);
|
|
|
|
|
|
if (_c > 0)
|
|
|
{
|
|
|
_r.Success = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
}
|
|
|
return _r;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 传入IDataReader 和字段名 和返回值类型
|
|
|
|
|
|
public static object getValue(IDataReader reader, string fieldname, string type = "")
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
reader.GetSchemaTable().DefaultView.RowFilter = "ColumnName= '" + fieldname + "'";
|
|
|
if (reader.GetSchemaTable().DefaultView.Count > 0)
|
|
|
{
|
|
|
var _r = reader[fieldname];
|
|
|
if (_r != DBNull.Value) return _r;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e) {
|
|
|
return null;
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 通过USERID/或者user.showname 获取邮箱和QQ
|
|
|
public static string GetPhoneWithUserId(string USERID, out string email, out string qq)
|
|
|
{
|
|
|
string sql = "select officephone,EMAIL1,QQ from user_baseinfo where (userid = '" + USERID + "' or userid in(select userid from vw_user where showname= '" + USERID + "') ) ";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
string phone = "";
|
|
|
email = "";
|
|
|
qq = "";
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
phone = reader["officephone"].ToString();
|
|
|
email = reader["EMAIL1"].ToString();
|
|
|
qq = reader["QQ"].ToString();
|
|
|
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return phone;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 查看reader中是否存在字段 bool
|
|
|
|
|
|
public static bool ReadFieldExist(IDataReader reader, string Fieldname)
|
|
|
{
|
|
|
reader.GetSchemaTable().DefaultView.RowFilter = "ColumnName= '" + Fieldname + "'";
|
|
|
if (reader.GetSchemaTable().DefaultView.Count > 0)
|
|
|
return true;
|
|
|
else return false;
|
|
|
//try
|
|
|
//{
|
|
|
// var index = reader.GetOrdinal(Fieldname);
|
|
|
// if (index > -1)
|
|
|
// return true;
|
|
|
// else return false;
|
|
|
//}
|
|
|
//catch {
|
|
|
// return false;
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
public object getRowValue(DataColumnCollection Columns, DataRow row, string fieldname)
|
|
|
{
|
|
|
|
|
|
if (Columns.Contains(fieldname)) return row[fieldname];
|
|
|
else return "";
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 将Excel单表转为Datatable
|
|
|
/// </summary>
|
|
|
/// <param name="stream"></param>
|
|
|
/// <param name="fileType"></param>
|
|
|
/// <param name="strMsg"></param>
|
|
|
/// <param name="sheetName"></param>
|
|
|
/// <returns></returns>
|
|
|
public static DataTable ExcelToDatatable(Stream stream, string fileType, out string strMsg, string sheetName = null)
|
|
|
{
|
|
|
strMsg = "";
|
|
|
DataTable dt = new DataTable();
|
|
|
ISheet sheet = null;
|
|
|
IWorkbook workbook = null;
|
|
|
try
|
|
|
{
|
|
|
#region 判断excel版本
|
|
|
//2007以上版本excel
|
|
|
if (fileType == ".xlsx")
|
|
|
{
|
|
|
workbook = new XSSFWorkbook(stream);
|
|
|
//workbook = WorkbookFactory.Create(stream);
|
|
|
}
|
|
|
//2007以下版本excel
|
|
|
else if (fileType == ".xls")
|
|
|
{
|
|
|
workbook = new HSSFWorkbook(stream);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
throw new Exception("传入的不是Excel文件!");
|
|
|
}
|
|
|
#endregion
|
|
|
if (!string.IsNullOrEmpty(sheetName))
|
|
|
{
|
|
|
sheet = workbook.GetSheet(sheetName);
|
|
|
if (sheet == null)
|
|
|
{
|
|
|
sheet = workbook.GetSheetAt(0);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sheet = workbook.GetSheetAt(0);
|
|
|
}
|
|
|
if (sheet != null)
|
|
|
{
|
|
|
IRow firstRow = sheet.GetRow(0);
|
|
|
int cellCount = firstRow.LastCellNum;
|
|
|
for (int i = firstRow.FirstCellNum; i < cellCount; i++)
|
|
|
{
|
|
|
ICell cell = firstRow.GetCell(i);
|
|
|
if (cell != null)
|
|
|
{
|
|
|
string cellValue = cell.StringCellValue.Trim();
|
|
|
if (!string.IsNullOrEmpty(cellValue))
|
|
|
{
|
|
|
DataColumn dataColumn = new DataColumn(cellValue);
|
|
|
dt.Columns.Add(dataColumn);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
DataRow dataRow = null;
|
|
|
//遍历行
|
|
|
for (int j = sheet.FirstRowNum + 1; j <= sheet.LastRowNum; j++)
|
|
|
{
|
|
|
IRow row = sheet.GetRow(j);
|
|
|
dataRow = dt.NewRow();
|
|
|
if (row == null || row.FirstCellNum < 0)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
//遍历列
|
|
|
for (int i = row.FirstCellNum; i < cellCount; i++)
|
|
|
{
|
|
|
ICell cellData = row.GetCell(i);
|
|
|
if (cellData != null && cellData.ToString() != "")
|
|
|
{
|
|
|
//判断是否为数字型,必须加这个判断不然下面的日期判断会异常
|
|
|
if (cellData.CellType == CellType.Numeric)
|
|
|
{
|
|
|
//判断是否日期类型
|
|
|
if (DateUtil.IsCellDateFormatted(cellData))
|
|
|
{
|
|
|
dataRow[i] = cellData.DateCellValue;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dataRow[i] = cellData.ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dataRow[i] = cellData.ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dataRow[i] = Guid.NewGuid().ToString();
|
|
|
}
|
|
|
}
|
|
|
dt.Rows.Add(dataRow);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
throw new Exception("没有获取到Excel中的数据表!");
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
workbook = new HSSFWorkbook(stream);
|
|
|
strMsg = ex.Message;
|
|
|
}
|
|
|
return dt;
|
|
|
}
|
|
|
|
|
|
|
|
|
#region 解析BC的pdf文档
|
|
|
public static DataTable ExcelToDatatable_2(Stream stream, string fileType, out string strMsg, string sheetName = null)
|
|
|
{
|
|
|
strMsg = "";
|
|
|
DataTable dt = new DataTable();
|
|
|
ISheet sheet = null;
|
|
|
IWorkbook workbook = null;
|
|
|
try
|
|
|
{
|
|
|
#region 判断excel版本
|
|
|
//2007以上版本excel
|
|
|
if (fileType == ".xlsx")
|
|
|
{
|
|
|
workbook = new XSSFWorkbook(stream);
|
|
|
//workbook = WorkbookFactory.Create(stream);
|
|
|
}
|
|
|
//2007以下版本excel
|
|
|
else if (fileType == ".xls")
|
|
|
{
|
|
|
workbook = new HSSFWorkbook(stream);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
throw new Exception("传入的不是Excel文件!");
|
|
|
}
|
|
|
#endregion
|
|
|
if (!string.IsNullOrEmpty(sheetName))
|
|
|
{
|
|
|
sheet = workbook.GetSheet(sheetName);
|
|
|
if (sheet == null)
|
|
|
{
|
|
|
sheet = workbook.GetSheetAt(0);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sheet = workbook.GetSheetAt(0);
|
|
|
}
|
|
|
if (sheet != null)
|
|
|
{
|
|
|
IRow firstRow = sheet.GetRow(sheet.FirstRowNum);
|
|
|
int cellCount = firstRow.LastCellNum;
|
|
|
for (int i = firstRow.FirstCellNum; i < cellCount; i++)
|
|
|
{
|
|
|
ICell cell = firstRow.GetCell(i);
|
|
|
if (cell != null)
|
|
|
{
|
|
|
string cellValue = cell.StringCellValue.Trim();
|
|
|
if (!string.IsNullOrEmpty(cellValue))
|
|
|
{
|
|
|
DataColumn dataColumn = new DataColumn(cellValue);
|
|
|
dt.Columns.Add(dataColumn);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
DataColumn dataColumn = new DataColumn(Guid.NewGuid().ToString());
|
|
|
dt.Columns.Add(dataColumn);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
DataRow dataRow = null;
|
|
|
//遍历行
|
|
|
for (int j = sheet.FirstRowNum + 1; j <= sheet.LastRowNum; j++)
|
|
|
{
|
|
|
IRow row = sheet.GetRow(j);
|
|
|
dataRow = dt.NewRow();
|
|
|
if (row == null || row.FirstCellNum < 0)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
//遍历列
|
|
|
for (int i = row.FirstCellNum; i < cellCount; i++)
|
|
|
{
|
|
|
ICell cellData = row.GetCell(i);
|
|
|
if (cellData != null && cellData.ToString() != "")
|
|
|
{
|
|
|
//判断是否为数字型,必须加这个判断不然下面的日期判断会异常
|
|
|
if (cellData.CellType == CellType.Numeric)
|
|
|
{
|
|
|
//判断是否日期类型
|
|
|
if (DateUtil.IsCellDateFormatted(cellData))
|
|
|
{
|
|
|
dataRow[i] = cellData.DateCellValue;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dataRow[i] = cellData.ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dataRow[i] = cellData.ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
//dataRow[i] = Guid.NewGuid().ToString();
|
|
|
dataRow[i] = "";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
dt.Rows.Add(dataRow);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
throw new Exception("没有获取到Excel中的数据表!");
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
workbook = new HSSFWorkbook(stream);
|
|
|
strMsg = ex.Message;
|
|
|
}
|
|
|
return dt;
|
|
|
}
|
|
|
|
|
|
public static string PDFTOEXCEL(string FileName)
|
|
|
{
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
|
|
|
PdfDocument pdf = new PdfDocument();
|
|
|
pdf.LoadFromFile(FileName);
|
|
|
|
|
|
var fullname = FileName + ".xlsx";
|
|
|
|
|
|
pdf.SaveToFile(fullname, Spire.Pdf.FileFormat.XLSX);
|
|
|
|
|
|
pdf.Close();
|
|
|
|
|
|
return fullname;
|
|
|
//return _webResponse.OK(fullname);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
//return _webResponse.Error(e.Message);
|
|
|
SaveLog(e.Message, "", "PDF转Excel", "");
|
|
|
return "";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public class 船名航次
|
|
|
{
|
|
|
public string 船名 { get; set; }
|
|
|
public string 航次 { get; set; }
|
|
|
|
|
|
public string ETD { get; set; }
|
|
|
|
|
|
public string ETA { get; set; }
|
|
|
public 船名航次() { }
|
|
|
public 船名航次(string vessel, string voyno, string etd = "", string eta = "")
|
|
|
{
|
|
|
船名 = vessel;
|
|
|
航次 = voyno;
|
|
|
ETD = etd;
|
|
|
ETD = eta;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public class BC_ExcelInfo
|
|
|
{
|
|
|
protected List<船名航次> InfoList { get; set; }
|
|
|
|
|
|
protected DataTable dt { get; set; }
|
|
|
|
|
|
public BC_ExcelInfo()
|
|
|
{
|
|
|
InfoList = new List<船名航次>();
|
|
|
}
|
|
|
|
|
|
protected string ErrorMsg { get; set; }
|
|
|
|
|
|
protected FileStream fs { get; set; }
|
|
|
|
|
|
public void Get_Info(string pdffile, int firstrow = 0)
|
|
|
{
|
|
|
|
|
|
var newfilename = PDFTOEXCEL(pdffile);
|
|
|
|
|
|
using (fs = new FileStream(newfilename, FileMode.Open))
|
|
|
{
|
|
|
int len = (int)fs.Length;
|
|
|
byte[] buf = new byte[len];
|
|
|
//文件流读入图像数据
|
|
|
fs.Read(buf, 0, len);
|
|
|
//创建内存流对象
|
|
|
//MemoryStream ms = new MemoryStream();
|
|
|
//图像数据由文件流写入内存流
|
|
|
//ms.Write(buf, 0, len);
|
|
|
fs.Seek(0, SeekOrigin.Begin);
|
|
|
var _ErrorMsg = "";
|
|
|
|
|
|
dt = ExcelToDatatable_2(fs, ".xlsx", out _ErrorMsg);
|
|
|
ErrorMsg = _ErrorMsg;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public void Set_Info() { }
|
|
|
|
|
|
public string GetValue(string fieldname)
|
|
|
{
|
|
|
if (fieldname == "船名")
|
|
|
{
|
|
|
if (InfoList.Count > 0)
|
|
|
{
|
|
|
return InfoList[0].船名;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (fieldname == "航次")
|
|
|
{
|
|
|
if (InfoList.Count > 0)
|
|
|
{
|
|
|
return InfoList[0].航次;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (fieldname == "ETD")
|
|
|
{
|
|
|
if (InfoList.Count > 0)
|
|
|
{
|
|
|
return InfoList[0].ETD;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (fieldname == "ETA")
|
|
|
{
|
|
|
if (InfoList.Count > 0)
|
|
|
{
|
|
|
return InfoList[0].ETA;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
|
|
|
protected bool 行存在某文本(DataRow dr, string str)
|
|
|
{
|
|
|
for (int i = 0; i < dt.Columns.Count; i++)
|
|
|
{
|
|
|
var columnvalue = dr[i].ToString();
|
|
|
|
|
|
if (columnvalue.Contains(str))
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
protected int 行序号(DataRow dr, string str)
|
|
|
{
|
|
|
for (int i = 0; i < dt.Columns.Count; i++)
|
|
|
{
|
|
|
var columnvalue = dr[i].ToString();
|
|
|
|
|
|
if (columnvalue.Contains(str))
|
|
|
{
|
|
|
return i;
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public class 中远BC_ExcelInfo : BC_ExcelInfo
|
|
|
{
|
|
|
private string 船名name = "Vessel Name";
|
|
|
private string 航次name = "Voyage";
|
|
|
private string nullname = "待定";
|
|
|
private string 结束name = "请注意:";
|
|
|
|
|
|
private string ETDname = "ETD";
|
|
|
private string ETAname = "ETA";
|
|
|
|
|
|
private int 船名列 = 4;
|
|
|
private int 航次列 = 7;
|
|
|
private int ETD列 = 7;
|
|
|
private int ETA列 = 7;
|
|
|
|
|
|
public 中远BC_ExcelInfo(string pdffile)
|
|
|
{
|
|
|
Get_Info(pdffile, 19);
|
|
|
Set_Info();
|
|
|
}
|
|
|
|
|
|
public string BC船名
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
if (InfoList.Count > 0)
|
|
|
{
|
|
|
return InfoList[0].船名;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public string BC航次
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
if (InfoList.Count > 0)
|
|
|
{
|
|
|
return InfoList[0].航次;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void Set_Info()
|
|
|
{
|
|
|
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
for (var line = 0; line < dt.Rows.Count; line++)
|
|
|
{
|
|
|
|
|
|
DataRow dr = dt.Rows[line];
|
|
|
for (int i = 0; i < dt.Columns.Count; i++)
|
|
|
{
|
|
|
var columnvalue = dr[i].ToString();
|
|
|
|
|
|
|
|
|
if (columnvalue.Contains(船名name))
|
|
|
{
|
|
|
//下面一行就是产品开始行 产品行数+1
|
|
|
var _船名航次行数 = 1;
|
|
|
var 船名航次行 = dt.Rows[line + _船名航次行数];
|
|
|
|
|
|
船名列 = 行序号(dr, 船名name);
|
|
|
航次列 = 行序号(dr, 航次name);
|
|
|
ETD列 = 行序号(dr, ETDname);
|
|
|
ETA列 = 行序号(dr, ETAname);
|
|
|
|
|
|
//再看它下面一行是否有备注名 如果有 那这行也是结束行 同时记录备注
|
|
|
//否则再下一行 同时产品行数+1
|
|
|
|
|
|
while (!行存在某文本(船名航次行, 结束name))
|
|
|
{
|
|
|
//var 行文本List = new List<string>();
|
|
|
|
|
|
var item = new 船名航次(船名航次行[船名列].ToString()
|
|
|
, 船名航次行[航次列].ToString()
|
|
|
, 船名航次行[ETD列].ToString()
|
|
|
, 船名航次行[ETA列].ToString()
|
|
|
);
|
|
|
|
|
|
if (item.船名 != nullname && !string.IsNullOrWhiteSpace(item.船名))
|
|
|
{
|
|
|
InfoList.Add(item);
|
|
|
}
|
|
|
_船名航次行数++;
|
|
|
船名航次行 = dt.Rows[line + _船名航次行数];
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public class 马士基BC_ExcelInfo : BC_ExcelInfo
|
|
|
{
|
|
|
private string 船名name = "Vessel";
|
|
|
private string 航次name = "Voy No.";
|
|
|
private string nullname = "";
|
|
|
private string 结束name = "this booking confirmation is subject to";
|
|
|
|
|
|
private string ETDname = "ETD";
|
|
|
private string ETAname = "ETA";
|
|
|
|
|
|
private int 船名列 = 17;
|
|
|
private int 航次列 = 24;
|
|
|
private int ETD列 = 7;
|
|
|
private int ETA列 = 7;
|
|
|
|
|
|
public 马士基BC_ExcelInfo(string pdffile)
|
|
|
{
|
|
|
Get_Info(pdffile, 19);
|
|
|
Set_Info();
|
|
|
}
|
|
|
|
|
|
public void Set_Info()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
for (var line = 0; line < dt.Rows.Count; line++)
|
|
|
{
|
|
|
|
|
|
DataRow dr = dt.Rows[line];
|
|
|
for (int i = 0; i < dt.Columns.Count; i++)
|
|
|
{
|
|
|
|
|
|
var columnvalue = dr[i].ToString();
|
|
|
|
|
|
|
|
|
if (行存在某文本(dr, 船名name) && 行存在某文本(dr, ETDname))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
//下面一行就是产品开始行 产品行数+1
|
|
|
var _船名航次行数 = 1;
|
|
|
var 船名航次行 = dt.Rows[line + _船名航次行数];
|
|
|
|
|
|
船名列 = 行序号(dr, 船名name);
|
|
|
航次列 = 行序号(dr, 航次name);
|
|
|
ETD列 = 行序号(dr, ETDname);
|
|
|
ETA列 = 行序号(dr, ETAname);
|
|
|
|
|
|
//再看它下面一行是否有备注名 如果有 那这行也是结束行 同时记录备注
|
|
|
//否则再下一行 同时产品行数+1
|
|
|
|
|
|
while (!行存在某文本(船名航次行, 结束name))
|
|
|
{
|
|
|
//var 行文本List = new List<string>();
|
|
|
|
|
|
var item = new 船名航次(船名航次行[船名列].ToString()
|
|
|
, 船名航次行[航次列].ToString()
|
|
|
, 船名航次行[ETD列].ToString()
|
|
|
, 船名航次行[ETA列].ToString()
|
|
|
);
|
|
|
|
|
|
if (item.船名 != nullname && !string.IsNullOrWhiteSpace(item.船名))
|
|
|
{
|
|
|
InfoList.Add(item);
|
|
|
}
|
|
|
_船名航次行数++;
|
|
|
船名航次行 = dt.Rows[line + _船名航次行数];
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
SaveLog(e.Message, "", "BS解析", "马士基BC");
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
SaveLog(e.Message, "", "BS解析", "马士基BC");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 接口类:分页查询语句的查询条件
|
|
|
/// strSql,strCondition,rangestr,sortstring,defaultsortstr,start,limit
|
|
|
/// </summary>
|
|
|
public class PagedQuaryParam
|
|
|
{
|
|
|
|
|
|
public string strSql { get; set; }
|
|
|
public string strCondition { get; set; }
|
|
|
public string rangestr { get; set; }
|
|
|
public string sortstring { get; set; }
|
|
|
public string defaultsortstr { get; set; }
|
|
|
public int start { get; set; }
|
|
|
public int limit { get; set; }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 分页查询语句
|
|
|
/// strSql查询语句必须包含where子句,没有的也要以where 1=1 结尾 。
|
|
|
/// </summary>
|
|
|
/// <param name="PagedQuaryParam"></param>
|
|
|
///
|
|
|
/// <returns></returns>
|
|
|
public static StringBuilder PagedQuaryStr(PagedQuaryParam PagedQuaryParam)
|
|
|
{
|
|
|
|
|
|
var result = new StringBuilder();
|
|
|
|
|
|
result.Append(@"SELECT * from (SELECT row_number() over (");
|
|
|
|
|
|
//if (PagedQuaryParam.sortstring.IndexOf("[{") >= 0) {
|
|
|
// PagedQuaryParam.sortstring = DatasetSort.Getsortstring(PagedQuaryParam.sortstring);
|
|
|
//}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(PagedQuaryParam.sortstring))
|
|
|
{
|
|
|
result.Append(" order by " + PagedQuaryParam.sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Append(" order by " + PagedQuaryParam.defaultsortstr);
|
|
|
}
|
|
|
result.Append(@") as num , * from (");
|
|
|
|
|
|
|
|
|
result.Append(PagedQuaryParam.strSql);
|
|
|
|
|
|
if (!string.IsNullOrEmpty(PagedQuaryParam.strCondition))
|
|
|
{
|
|
|
result.Append(" and " + PagedQuaryParam.strCondition);
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(PagedQuaryParam.rangestr))
|
|
|
{
|
|
|
result.Append(" and " + PagedQuaryParam.rangestr);
|
|
|
}
|
|
|
result.Append(@")as t )as t2 ");
|
|
|
result.Append(string.Format(" where t2.num>{0} and t2.num<={1} ", PagedQuaryParam.start, PagedQuaryParam.start + PagedQuaryParam.limit)); //
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
public static int PagedCount(PagedQuaryParam PagedQuaryParam)
|
|
|
{
|
|
|
var result = 0;
|
|
|
|
|
|
StringBuilder sqlstr = new StringBuilder();
|
|
|
sqlstr.Append(@"SELECT count(*) _count from ( ");
|
|
|
sqlstr.Append(PagedQuaryParam.strSql);
|
|
|
if (!string.IsNullOrEmpty(PagedQuaryParam.strCondition))
|
|
|
{
|
|
|
sqlstr.Append(" and " + PagedQuaryParam.strCondition);
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(PagedQuaryParam.rangestr))
|
|
|
{
|
|
|
sqlstr.Append(" and " + PagedQuaryParam.rangestr);
|
|
|
}
|
|
|
sqlstr.Append(@") as t ");
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
try
|
|
|
{
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sqlstr.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
result = (reader["_count"] == null ? 0 : Convert.ToInt32(reader["_count"]));
|
|
|
}
|
|
|
|
|
|
//#region 空白项
|
|
|
//DICModel data2 = new DICModel();
|
|
|
//data2.KEYFIELD = "";//惟一值
|
|
|
//data2.VALUEFIELD = "0";//惟一值
|
|
|
//#endregion
|
|
|
//headList.Add(data2);
|
|
|
reader.Close();
|
|
|
}
|
|
|
}
|
|
|
catch { }
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
#region 获取数据表数据的刷新时间 以供前台决定是否更新表 以及刷新mainform上面的store
|
|
|
//此处只有第一次被读取时才读取数据库 之后都是直接返回内存数值
|
|
|
//setnew方法更新某个表名的刷新时间时,会同时更新内存内的刷新时间
|
|
|
//但是如果新增一种表名的话,需要重新启动网站服务,否则内存表内容无法添加。
|
|
|
//public static List<StoreModifyResultStatus> GetTableStatusList()
|
|
|
//{
|
|
|
// try
|
|
|
// {
|
|
|
|
|
|
// if (StoreModifyStatusMb.StoreModifyStatusList == null || StoreModifyStatusMb.StoreModifyStatusList.Count == 0)
|
|
|
// {
|
|
|
// ResetStoreModifyStatus();
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// //var _result = SetStoreModifyStatus(StoreModifyStatusMb.getSql());
|
|
|
|
|
|
|
|
|
// //StoreModifyStatusMb.setList(_result);
|
|
|
|
|
|
|
|
|
// //return getSql
|
|
|
// }
|
|
|
// return StoreModifyStatusMb.getstatus();
|
|
|
// }
|
|
|
// catch (Exception e)
|
|
|
// {
|
|
|
// SaveLog(e.Message, "", "提前缓存表", "GetTableStatusList");
|
|
|
// ResetStoreModifyStatus();
|
|
|
// return StoreModifyStatusMb.getstatus();
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
|
|
|
public static object GetStoreModifyStatusCache()
|
|
|
{
|
|
|
System.Web.Caching.Cache objCache = HttpRuntime.Cache;
|
|
|
return objCache["StoreModifyStatus"];
|
|
|
}
|
|
|
|
|
|
public static void SetStoreModifyStatusCache(List<StoreModifyStatusMb> StoreModifyStatusMb)
|
|
|
{
|
|
|
System.Web.Caching.Cache objCache = HttpRuntime.Cache;
|
|
|
//objCache.Remove("StoreModifyStatus");
|
|
|
objCache.Insert("StoreModifyStatus", StoreModifyStatusMb);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新公共store的刷新时间
|
|
|
/// </summary>
|
|
|
/// <param name="STORENAME"></param>
|
|
|
/// <returns></returns>
|
|
|
//public static DBResult PubStore_SetNew(string TABLENAME)
|
|
|
//{
|
|
|
// return StoreStatus_SetTime(TABLENAME);
|
|
|
//}
|
|
|
|
|
|
//public static DBResult StoreStatus_SetTime(string TABLENAME)
|
|
|
//{
|
|
|
// try
|
|
|
// {
|
|
|
// DBResult result = new DBResult();
|
|
|
// if (StoreModifyStatusMb.StoreModifyStatusList.Exists(t => t.TABLENAME == TABLENAME))
|
|
|
// {
|
|
|
// var modb = new ModelObjectDB();
|
|
|
// var _tlist = StoreModifyStatusMb.StoreModifyStatusList.FindAll(t => t.TABLENAME == TABLENAME);
|
|
|
|
|
|
// foreach (var _t in _tlist)
|
|
|
// {
|
|
|
// _t.MODIFIEDTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
// _t.DbOperationType = DbOperationType.DbotUpd;
|
|
|
// _t.ModelUIStatus = "E";
|
|
|
// _t.PubStoreList.Clear();
|
|
|
// result = modb.Save(_t);
|
|
|
// }
|
|
|
|
|
|
// return result;
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
|
|
|
// var er = new DBResult(false, "没有该表名的配置信息", null);
|
|
|
// return er;
|
|
|
|
|
|
// }
|
|
|
// }
|
|
|
// catch (Exception e)
|
|
|
// {
|
|
|
// SaveLog(e.Message, "", "提前缓存表", "StoreStatus_SetTime");
|
|
|
|
|
|
// BasicDataRefDAL.ResetStoreModifyStatus();
|
|
|
|
|
|
// return StoreStatus_SetTime(TABLENAME);
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
|
|
|
//private static List<StoreModifyStatusMb> SetStoreModifyStatus(string strSql)
|
|
|
//{
|
|
|
// var headList = new List<StoreModifyStatusMb>();
|
|
|
// Database db = DatabaseFactory.CreateDatabase();
|
|
|
// try
|
|
|
// {
|
|
|
// using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
// {
|
|
|
// while (reader.Read())
|
|
|
// {
|
|
|
// StoreModifyStatusMb data = new StoreModifyStatusMb();
|
|
|
// #region Set DB data to Object
|
|
|
// data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));
|
|
|
// data.TABLENAME = (reader["TABLENAME"] == null ? "" : Convert.ToString(reader["TABLENAME"]));
|
|
|
// data.STORENAME = (reader["STORENAME"] == null ? "" : Convert.ToString(reader["STORENAME"]));
|
|
|
// data.DISPLAYFIELD = (reader["DISPLAYFIELD"] == null ? "" : Convert.ToString(reader["DISPLAYFIELD"]));
|
|
|
// data.VALUEFIELD = (reader["VALUEFIELD"] == null ? "" : Convert.ToString(reader["VALUEFIELD"]));
|
|
|
// data.DISPLAYFIELD2 = (reader["DISPLAYFIELD2"] == null ? "" : Convert.ToString(reader["DISPLAYFIELD2"]));
|
|
|
// data.CONDITION = (reader["CONDITION"] == null ? "" : Convert.ToString(reader["CONDITION"]));
|
|
|
// data.MODIFIEDTIME = (reader["MODIFIEDTIME"] == null ? "" : Convert.ToString(reader["MODIFIEDTIME"]));
|
|
|
// #endregion
|
|
|
// headList.Add(data);
|
|
|
// }
|
|
|
|
|
|
// //#region 空白项
|
|
|
// //DICModel data2 = new DICModel();
|
|
|
// //data2.KEYFIELD = "";//惟一值
|
|
|
// //data2.VALUEFIELD = "0";//惟一值
|
|
|
// //#endregion
|
|
|
// //headList.Add(data2);
|
|
|
// reader.Close();
|
|
|
// }
|
|
|
// }
|
|
|
// catch (Exception e)
|
|
|
// {
|
|
|
// SaveLog(e.Message, "", "提前缓存表", "SetStoreModifyStatus");
|
|
|
// }
|
|
|
// return headList;
|
|
|
//}
|
|
|
|
|
|
//public static void ResetStoreModifyStatus()
|
|
|
//{
|
|
|
// var _list = SetStoreModifyStatus(StoreModifyStatusMb.getSql());
|
|
|
// SetStoreModifyStatusCache(_list);
|
|
|
// //StoreModifyStatusMb.setList(_list);
|
|
|
//}
|
|
|
|
|
|
static public List<PubStoremb> getPubExtendStore(string strSql)
|
|
|
{
|
|
|
|
|
|
var headList = new List<PubStoremb>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
string sql = strSql.ToString();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
|
|
|
////根据字段名设定同名属性值
|
|
|
PubStoremb data = new PubStoremb();
|
|
|
data.SetExtendValue(reader);
|
|
|
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
if (headList.Count > 0)
|
|
|
{
|
|
|
var Model = headList[0];
|
|
|
PubStoremb data0 = new PubStoremb();
|
|
|
data0.SetExtendValue_Null(Model.ExtendDic);
|
|
|
headList.Insert(0, data0);
|
|
|
}
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 判断用户是否已登陆超时
|
|
|
/// <summary>
|
|
|
/// 判断用户是否已登陆超时
|
|
|
/// </summary>
|
|
|
/// <param name="Session"></param>
|
|
|
/// <returns></returns>
|
|
|
public static DBResult CheckLogin(HttpSessionStateBase Session)
|
|
|
{
|
|
|
|
|
|
var result = new DBResult();
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
var _r = new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
result.SetErrorInfo("", false, _r);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.setMessage(true, "");
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 多种业务使用的业务信息查询
|
|
|
|
|
|
static public List<VOPBSmb> getVOPBSStore(int start, int limit, string OPLB, string condition, string sort = "")
|
|
|
{
|
|
|
|
|
|
var headList = new List<VOPBSmb>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
PagedQuaryParam pp = new PagedQuaryParam();
|
|
|
|
|
|
pp.strSql = $" select * from v_op_bs where 1=1 ";
|
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(OPLB))
|
|
|
pp.strSql = $" select * from v_op_bs where OPLB='{OPLB}' ";
|
|
|
|
|
|
pp.start = start;
|
|
|
pp.limit = limit;
|
|
|
pp.strCondition = condition;
|
|
|
pp.defaultsortstr = "CUSTNO";
|
|
|
pp.sortstring = sort;
|
|
|
|
|
|
var strSql = PagedQuaryStr(pp);
|
|
|
|
|
|
string sql = strSql.ToString();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
|
|
|
////根据字段名设定同名属性值
|
|
|
VOPBSmb data = new VOPBSmb();
|
|
|
data.SetExtendValue(reader);
|
|
|
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 返回程序目录下一个文件夹 如不存在则创建
|
|
|
public static string getPath(string FILEPATH)
|
|
|
{
|
|
|
var path = AppDomain.CurrentDomain.BaseDirectory + FILEPATH + @"\";
|
|
|
if (Directory.Exists(path) == false)
|
|
|
{
|
|
|
Directory.CreateDirectory(path);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
}
|
|
|
return path;
|
|
|
}
|
|
|
public static void ClearPath(string FILEPATH)
|
|
|
{
|
|
|
foreach (string f in Directory.GetFileSystemEntries(FILEPATH))
|
|
|
{
|
|
|
if (File.Exists(f))
|
|
|
{
|
|
|
//如果有子文件删除文件
|
|
|
File.Delete(f);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 下载指定URL的文件到指定路径,文件名为指定
|
|
|
public static string HttpDownloadFile(string remoteUrl, string FILEPATH, string FILENAME)
|
|
|
{
|
|
|
// 设置参数
|
|
|
HttpWebRequest request = WebRequest.Create(remoteUrl) as HttpWebRequest;
|
|
|
//发送请求并获取相应回应数据
|
|
|
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
|
|
|
//直到request.GetResponse()程序才开始向目标网页发送Post请求
|
|
|
Stream responseStream = response.GetResponseStream();
|
|
|
|
|
|
var path = getPath(FILEPATH);
|
|
|
|
|
|
string localPath = path + FILENAME;
|
|
|
|
|
|
if (File.Exists(localPath))
|
|
|
{
|
|
|
return localPath;
|
|
|
}
|
|
|
|
|
|
//创建本地文件写入流
|
|
|
Stream stream = new FileStream(localPath, FileMode.Create);
|
|
|
byte[] bArr = new byte[1024];
|
|
|
int size = responseStream.Read(bArr, 0, (int)bArr.Length);
|
|
|
while (size > 0)
|
|
|
{
|
|
|
stream.Write(bArr, 0, size);
|
|
|
size = responseStream.Read(bArr, 0, (int)bArr.Length);
|
|
|
}
|
|
|
stream.Close();
|
|
|
responseStream.Close();
|
|
|
return localPath;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 通用excel上传解析 参数为control的 Request 返回值为一个数据表1转换成的datatable
|
|
|
/// <summary>
|
|
|
/// 通用excel上传解析 返回文件名
|
|
|
/// </summary>
|
|
|
/// <param name="filepath">目标文件夹名【需形如 /xxxx 】 默认【../../UploadFiles】</param>
|
|
|
/// <returns></returns>
|
|
|
public static DBResult RequestExceltoDatatable(HttpRequestBase Request, out DataTable dt)
|
|
|
{
|
|
|
var result = new DBResult(false, "");
|
|
|
dt = new DataTable();
|
|
|
if (Request.Files.Count == 0)
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "参数错误";
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
try
|
|
|
{
|
|
|
var excelfile = Request.Files[0];
|
|
|
string strMsg;
|
|
|
string ext = Path.GetExtension(excelfile.FileName).ToLower();
|
|
|
if (ext != ".xls" && ext != ".xlsx")
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "文件必须为EXCEL格式!";
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
dt = ExcelToDatatable(excelfile.InputStream, ext, out strMsg);
|
|
|
if (!string.IsNullOrEmpty(strMsg))
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = strMsg;
|
|
|
return result;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = true;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
result.SetErrorInfo(e.Message);
|
|
|
}
|
|
|
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 检查USERID对于一个action是否有查看权限 CheckAuthority
|
|
|
public static Boolean CheckAuthority(string USERID, string MODNAME)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string sSQL = $" USERID = '{USERID}' AND ACTIONID in(select gid from [action] where NAME='{MODNAME}')";
|
|
|
int recordCount = new user_actionBLL().GetRecordCount(sSQL);
|
|
|
|
|
|
if (recordCount > 0) return true;
|
|
|
if (recordCount == 0) return false;
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region MD5值
|
|
|
|
|
|
public static string GetMd5Hash(string str)
|
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(str))
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
MD5 md5hash = MD5.Create();
|
|
|
|
|
|
byte[] data = md5hash.ComputeHash(Encoding.UTF8.GetBytes(str));
|
|
|
|
|
|
StringBuilder sBuilder = new StringBuilder();
|
|
|
|
|
|
for (int i = 0; i < data.Length; i++)
|
|
|
{
|
|
|
sBuilder.Append(data[i].ToString("x2"));
|
|
|
}
|
|
|
return sBuilder.ToString();
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
public static ContentResult GetContentResult(DBResult dbresult)
|
|
|
{
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = dbresult.Success,
|
|
|
Message = dbresult.Message,
|
|
|
Data = null
|
|
|
};
|
|
|
if (dbresult.Data != null) jsonRespose.Data = dbresult.Data;
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
public static ContentResult GetDataListContentResult(DBResult dbresult)
|
|
|
{
|
|
|
var json = JsonConvert.Serialize(new { Success = dbresult.Success, Message = dbresult.Message });
|
|
|
if (dbresult.Data != null) json = JsonConvert.Serialize(new { Success = true, Message = dbresult.Message, data = dbresult.Data });
|
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
|
|
|
public static DateTime ConvertLongToDateTime(long? d)
|
|
|
{
|
|
|
DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
|
|
long lTime = long.Parse(d + "0000");
|
|
|
TimeSpan toNow = new TimeSpan(lTime);
|
|
|
DateTime dtResult = dtStart.Add(toNow);
|
|
|
return dtResult;
|
|
|
}
|
|
|
|
|
|
|
|
|
public static string ConvertToChineseMoney(double money)
|
|
|
{
|
|
|
if (money < 0)
|
|
|
{
|
|
|
throw new ArgumentOutOfRangeException($"参数 money 不能为负值!");
|
|
|
}
|
|
|
string s = money.ToString("#L#E#D#C#K#E#D#C#J#E#D#C#I#E#D#C#H#E#D#C#G#E#D#C#F#E#D#C#.0B0A");
|
|
|
s = Regex.Replace(s, @"((?<=-|^)[^1-9]*)|((?'z'0)[0A-E]*((?=[1-9])
|
|
|
|(?'-z'(?=[F-L\.]|$))))|((?'b'[F-L])(?'z'0)[0A-L]*((?=[1-9])|(?'-z'(?=[\.]|$))))", "${b}${z}");
|
|
|
return Regex.Replace(s, ".", delegate (System.Text.RegularExpressions.Match m)
|
|
|
{
|
|
|
return "负元空零壹贰叁肆伍陆柒捌玖空空空空空空空分角拾佰仟萬億兆京垓秭穰"[m.Value[0] - '-'].ToString();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
public static string ConvertToChineseMoney2(double money)
|
|
|
{
|
|
|
var result = ConvertToChineseMoney(money);
|
|
|
|
|
|
var lastchar = result.Substring(result.Length - 1, 1);
|
|
|
if (lastchar == "角" || lastchar == "分")
|
|
|
{
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
result += "整";
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 海运出口的合规检验 http://60.209.125.238:32222/manage/file
|
|
|
/// senderId:DongshengPlat
|
|
|
///senderName:东胜平台
|
|
|
///senderKey:TTRQaHF2STczQ055S0lQV0duQTJaQVoydUpUOUlaMENaMUU2cFdJVnpVaEExOG4zVHMvcmQzL0RETWNjK2tsbjlKeDhRand6Uit4TForVzZiUmtCeURuS29XY1JKU0R0cU5QYzA0Z0l0UkE9
|
|
|
/// url:http://60.209.125.238:35210/api/RulesEngineManage/ExcuteWorkFlow
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="BSNO"></param>
|
|
|
/// <returns></returns>
|
|
|
public static DBResult RulesManage_OPSEAE(string BSNO) {
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
var url = "http://60.209.125.238:35210/api/RulesEngineManage/ExcuteWorkFlow";
|
|
|
|
|
|
var head = MsOpSeaeDAL.GetData(" B.BSNO='" + BSNO + "'");
|
|
|
var sendobject = GetRuleObject("opseae", head);
|
|
|
|
|
|
//var msg = JsonConvert.Serialize(sendobject);
|
|
|
|
|
|
string rtn = WebRequestHelper.DoPost_Json(url, sendobject);
|
|
|
|
|
|
var ruleresult = JsonConvert.Deserialize<RulesEngineResult_Root>(rtn);
|
|
|
|
|
|
//var msg = "";
|
|
|
//foreach (var detail in ruleresult.extra.detailList) {
|
|
|
// msg += detail.resultName+"\r\n";
|
|
|
//}
|
|
|
|
|
|
result.Data = ruleresult;
|
|
|
result.OK("校验完成");
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
public static RulesEngineOrderBooking_Root GetRuleObject(string OPLBNAME, object _head)
|
|
|
{
|
|
|
|
|
|
var result = new RulesEngineOrderBooking_Root();
|
|
|
|
|
|
int GetInt(string str)
|
|
|
{
|
|
|
return string.IsNullOrWhiteSpace(str) ? 0 : Convert.ToInt32(Convert.ToDecimal(str));
|
|
|
}
|
|
|
|
|
|
if (OPLBNAME == "opseae")
|
|
|
{
|
|
|
var head = (MsOpSeae)_head;
|
|
|
var ams = MsOpSeaeEdiPortDAL.GetAmsData("BSNO='" + head.BSNO + "'");
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
result.head.senderKey = "TTRQaHF2STczQ055S0lQV0duQTJaQVoydUpUOUlaMENaMUU2cFdJVnpVaEExOG4zVHMvcmQzL0RETWNjK2tsbjlKeDhRand6Uit4TForVzZiUmtCeURuS29XY1JKU0R0cU5QYzA0Z0l0UkE9";
|
|
|
result.head.gid = head.BSNO;
|
|
|
result.head.messageType = "BUSI_RULE";
|
|
|
result.head.senderId = "DongshengPlat";
|
|
|
result.head.senderName = "东胜平台";
|
|
|
result.head.receiverId = "RulesEngine";
|
|
|
result.head.receiverName = "大简云规则引擎";
|
|
|
result.head.token = null;
|
|
|
result.head.version = "1.0";
|
|
|
result.head.requestDate = DateTime.Now;
|
|
|
result.head.requestAction = "CheckRule";
|
|
|
|
|
|
result.main.projectCode.Add("OCEAN_BOOKING");
|
|
|
|
|
|
var bi = new BusinessInfo();
|
|
|
|
|
|
bi.masterBlNo = head.MBLNO;
|
|
|
bi.houseBlNo = head.HBLNO;
|
|
|
bi.bookingNo = head.ORDERNO;
|
|
|
bi.contrNo = head.CONTRACTNO;
|
|
|
//result.main.businessInfo.servContrNo = head.CONTRACTNO;
|
|
|
bi.shipperId = head.SHIPPERID;
|
|
|
bi.consigneeId = head.CONSIGNEEID;
|
|
|
bi.notifyPartyId = head.NOTIFYPARTYID;
|
|
|
bi.shipper = head.SHIPPER;
|
|
|
bi.consignee = head.CONSIGNEE;
|
|
|
bi.notifyParty = head.NOTIFYPARTY;
|
|
|
//.notifyPrt2 = head.no
|
|
|
//bi.yardId = head.YARD;
|
|
|
bi.yard = head.YARD;
|
|
|
bi.vesselId = head.VESSELID;
|
|
|
bi.vessel = head.VESSEL;
|
|
|
bi.voyno = head.VOYNO;
|
|
|
//bi.voynoIn=head.VOYNO内部航次号
|
|
|
bi.etd = head.ETD;
|
|
|
bi.atd = head.ATD;
|
|
|
bi.eta = head.ETA;
|
|
|
bi.closingDate = head.CLOSINGDATE;
|
|
|
bi.closeDocDate = head.CLOSEDOCDATE;
|
|
|
//bi.closeVGMDate=head.clo 截VGM日期
|
|
|
bi.placeReceiptId = head.PLACERECEIPTID;
|
|
|
bi.placeReceipt = head.PLACERECEIPT;
|
|
|
bi.portLoadId = head.PORTLOADID;
|
|
|
bi.portLoad = head.PORTLOAD;
|
|
|
bi.portDischargeId = head.PORTDISCHARGEID;
|
|
|
bi.portDischarge = head.PORTDISCHARGE;
|
|
|
bi.placeDeliveryId = head.PLACEDELIVERYID;
|
|
|
bi.placeDelivery = head.PLACEDELIVERY;
|
|
|
bi.destinationId = head.DESTINATIONID;
|
|
|
bi.destination = head.DESTINATION;
|
|
|
bi.noBill = head.NOBILL;
|
|
|
bi.copyNoBill = head.COPYNOBILL;
|
|
|
|
|
|
bi.issueType = head.ISSUETYPE;
|
|
|
var issutypeedicode = cdc.code_issutype_edi.FirstOrDefault(x => x.EDINAME == "DJY" && x.BLTYPE == head.ISSUETYPE);
|
|
|
|
|
|
if (issutypeedicode != null && !string.IsNullOrWhiteSpace(issutypeedicode.EDICODE))
|
|
|
{
|
|
|
bi.issueType = issutypeedicode.EDICODE;
|
|
|
}
|
|
|
|
|
|
|
|
|
bi.issueDate = head.ISSUEDATE;
|
|
|
bi.issuePlaceId = head.ISSUEPLACEID;
|
|
|
bi.issuePlace = head.ISSUEPLACE;
|
|
|
bi.blfrt = head.BLFRT;
|
|
|
bi.prepardAt = head.PREPARDAT;
|
|
|
bi.payableAt = head.PAYABLEAT;
|
|
|
bi.service = head.SERVICE;
|
|
|
bi.marks = head.MARKS;
|
|
|
bi.hsCode = head.HSCODE;
|
|
|
bi.goodsDescription = head.DESCRIPTION;
|
|
|
bi.pkGs = GetInt(head.PKGS);
|
|
|
bi.kindPKGs = head.KINDPKGS;
|
|
|
bi.kGs = GetInt(head.KGS);
|
|
|
bi.cbm = GetInt(head.CBM);
|
|
|
bi.totalNO = head.TOTALNO;
|
|
|
bi.cntrTotal = head.CNTRTOTAL;
|
|
|
|
|
|
bi.carrierId = head.CARRIER;
|
|
|
var edicode = cdc.CodeCustEdi.FirstOrDefault(x => x.EDINAME == "DJY" && x.CUST == head.CARRIER);
|
|
|
|
|
|
if (edicode != null && !string.IsNullOrWhiteSpace(edicode.EDICODE)) {
|
|
|
bi.carrierId = edicode.EDICODE;
|
|
|
}
|
|
|
|
|
|
|
|
|
bi.carrier = head.CARRIER;
|
|
|
bi.cargoId = head.CARGOID;
|
|
|
bi.dClass = head.DCLASS;
|
|
|
bi.dUnno = head.DUNNO;
|
|
|
bi.dPage = head.DPAGE;
|
|
|
bi.dLabel = head.DLABEL;
|
|
|
bi.dLinkMan = head.LINKMAN;
|
|
|
bi.tempId = head.TEMPID;
|
|
|
bi.tempSet = head.TEMPSET;
|
|
|
bi.reeferf = head.REEFERF;
|
|
|
bi.humidity = head.HUMIDITY;
|
|
|
bi.tempMin = head.TEMPMIN;
|
|
|
bi.tempMax = head.TEMPMAX;
|
|
|
bi.isContaSOC = head.ISCONTAINERSOC;
|
|
|
bi.soRemark = ams.ORDERREMARK;
|
|
|
bi.siRemark = ams.SIREMARK;
|
|
|
//bi.yardRemark=head.yra场站备注
|
|
|
bi.compId = head.CORPID;
|
|
|
|
|
|
bi.compName = head.SALECORP;//公司名称
|
|
|
bi.shipperName = head.MSHIPPER;
|
|
|
bi.shipperAddr1 = ams.SHIPPERADDR1;
|
|
|
bi.shipperAddr2 = ams.SHIPPERADDR2;
|
|
|
bi.shipperAddr3 = ams.SHIPPERADDR3;
|
|
|
bi.shipperCity = ams.SHIPPERCITY;
|
|
|
bi.shipperProvice = ams.SHIPPERPROVINCE;
|
|
|
bi.shipperPostCode = ams.SHIPPERPOSTCODE;
|
|
|
bi.shipperCountry = ams.SHIPPERCOUNTRY;
|
|
|
bi.shipperAttn = ams.SHIPPERATTN;
|
|
|
bi.shipperTel = ams.SHIPPERTEL;
|
|
|
bi.consigneeName = ams.CONSIGNEENAME;
|
|
|
bi.consigneeAddr1 = ams.CONSIGNEEADDR1;
|
|
|
bi.consigneeAddr2 = ams.CONSIGNEEADDR2;
|
|
|
bi.consigneeAddr3 = ams.CONSIGNEEADDR3;
|
|
|
bi.consigneeCity = ams.CONSIGNEECITY;
|
|
|
bi.consigneeProvince = ams.CONSIGNEEPROVINCE;
|
|
|
bi.consigneePostCode = ams.CONSIGNEEPOSTCODE;
|
|
|
bi.consigneeCountry = ams.CONSIGNEECOUNTRY;
|
|
|
bi.consigneeAttn = ams.CONSIGNEEATTN;
|
|
|
bi.consigneeTel = ams.CONSIGNEETEL;
|
|
|
bi.notifyPartyName = ams.NOTIFYPARTYNAME;
|
|
|
bi.notifyPartyAddr1 = ams.NOTIFYPARTYADDR1;
|
|
|
bi.notifyPartyAddr2 = ams.NOTIFYPARTYADDR2;
|
|
|
bi.notifyPartyAddr3 = ams.NOTIFYPARTYADDR3;
|
|
|
bi.notifyPartyCity = ams.NOTIFYPARTYCITY;
|
|
|
bi.notifyPartyProvince = ams.NOTIFYPARTYPROVINCE;
|
|
|
bi.notifyPartyPostCode = ams.NOTIFYPARTYPOSTCODE;
|
|
|
bi.notifyPartyCountry = ams.NOTIFYPARTYCOUNTRY;
|
|
|
bi.notifyPartyAttn = ams.NOTIFYPARTYATTN;
|
|
|
bi.notifyPartyTel = ams.NOTIFYPARTYTEL;
|
|
|
//bi.poNo=
|
|
|
//bi.opid = head.OP;
|
|
|
//bi.docid = head.DOC;
|
|
|
bi.op = head.OP;
|
|
|
bi.doc = head.DOC;
|
|
|
//bi.saleId
|
|
|
bi.sale = head.SALE;
|
|
|
//bi.custserviceId
|
|
|
bi.custservice = head.CUSTSERVICE;
|
|
|
//bi.custserviceName
|
|
|
bi.forwarder = head.FORWARDER;
|
|
|
bi.shipAgency = head.SHIPAGENCY;
|
|
|
bi.customsER = head.CUSTOMSER;
|
|
|
bi.truckER = head.TRUCKER;
|
|
|
bi.agentId = head.AGENTID;
|
|
|
//bi.customerId=head.customerid
|
|
|
//bi.forwarderId=head.forw
|
|
|
//bi.shipAgencyId=head.SHIPAGENCY
|
|
|
//bi.customsERId=head.customserid
|
|
|
//bi.truckERId
|
|
|
//bi.agentName=head.agen
|
|
|
//bi.weiTo=
|
|
|
bi.consigneeDoorAddr = ams.DOORADDR;
|
|
|
//bi.shipperDoorAddr
|
|
|
bi.scacCode = ams.SCACCODE;
|
|
|
bi.itnCode = ams.ITNCODE;
|
|
|
bi.prePardAtId = head.PREPARDATID;
|
|
|
bi.payableAtId = head.PAYABLEAT;
|
|
|
bi.custNo = head.CUSTNO;
|
|
|
//bi.transportId =
|
|
|
bi.transport = head.TRANSPORT;
|
|
|
//bi.thirdPayAddr=ams.t
|
|
|
//bi.yardContractTel = head.YARDTEL;
|
|
|
//bi.yardContractEmail = ams.yard
|
|
|
//bi.feeSelf=head.feeself
|
|
|
|
|
|
//bi.laneCode = head.LANE;//航线代码 需确定如何取值
|
|
|
//bi.laneName = head.LANE;
|
|
|
bi.freightPayer = ams.FREIGHTPAYER;
|
|
|
//bi.shipperTaxNo = ams.shippertax
|
|
|
bi.consigneeTaxNo = ams.CONSIGNEETAXNO;
|
|
|
bi.notifyPartyTaxNo = ams.NOTIFYPARTYTAXNO;
|
|
|
|
|
|
bi.isATDChangeIssueType = null;
|
|
|
bi.isEngChinaLineBar = null;
|
|
|
bi.isDoubleShipper = null;
|
|
|
bi.isFCLAndLCLMix = null;
|
|
|
|
|
|
bi.isMutipleGoods = false; //多品名
|
|
|
|
|
|
bi.isContaLCL = false;//是否拼箱 装运方式
|
|
|
if (string.IsNullOrWhiteSpace(head.BLTYPE)) {
|
|
|
|
|
|
if (head.BLTYPE.IndexOf("整箱") >= 0)
|
|
|
bi.isContaLCL = false;
|
|
|
if (head.BLTYPE.IndexOf("拼箱") >= 0)
|
|
|
bi.isContaLCL = true;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(head.PORTDISCHARGEID)) {
|
|
|
|
|
|
if (head.PORTDISCHARGEID.Length >= 2)
|
|
|
bi.portDischargeCountryNo = head.PORTDISCHARGEID.Substring(0, 2);
|
|
|
|
|
|
var dischargecountry = cdc.code_country.FirstOrDefault(x => x.COUNTRYID == bi.portDischargeCountryNo);
|
|
|
if (dischargecountry != null) {
|
|
|
bi.portDischargeEN = dischargecountry.getCnName();
|
|
|
|
|
|
bi.portDischargeCN = dischargecountry.getCnName();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(head.TRANSPORT))
|
|
|
{
|
|
|
if (head.TRANSPORT.Length >= 2)
|
|
|
bi.transportCountryNo = head.TRANSPORT.Substring(0, 2);
|
|
|
|
|
|
var transportcountry = cdc.code_country.FirstOrDefault(x => x.COUNTRYID == bi.transportCountryNo);
|
|
|
if (transportcountry != null)
|
|
|
{
|
|
|
bi.transportEN = transportcountry.getEnName();
|
|
|
|
|
|
bi.transportCN = transportcountry.getCnName();
|
|
|
}
|
|
|
//bi.transportCountryNo
|
|
|
//bi.transportEN
|
|
|
//bi.transportCN
|
|
|
}
|
|
|
//result.main.businessInfo = bi;
|
|
|
|
|
|
var OpCtnlist = MsOpSeaeDAL.GetBodyList("BSNO='" + head.BSNO + "'");
|
|
|
|
|
|
var OpCtnDetailList = MsOpSeaeDAL.GetOpCtnDetailList("[CTN_ID] in (select [CTN_ID] from op_ctn where BSNO='" + head.BSNO + "')");
|
|
|
|
|
|
//多品名
|
|
|
if (OpCtnDetailList != null && OpCtnDetailList.Count > 0) {
|
|
|
bi.isMutipleGoods = true; //多品名
|
|
|
}
|
|
|
|
|
|
if (OpCtnlist != null && OpCtnlist.Count > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
bi.contaList = new List<ContaList>();
|
|
|
|
|
|
foreach (var ctn in OpCtnlist) {
|
|
|
|
|
|
var codectn = cdc.CODE_CTN.FirstOrDefault(x => x.CTN == ctn.CTNALL);
|
|
|
|
|
|
var newcon = new ContaList {
|
|
|
contaType = codectn.EDICODE,
|
|
|
contaTypeName = ctn.CTNALL,
|
|
|
teu = codectn.TEU.ToString(),
|
|
|
contaNo = ctn.CNTRNO,
|
|
|
sealNo = ctn.SEALNO,
|
|
|
pkGs = ctn.PKGS,
|
|
|
kindPKGs = ctn.KINDPKGS,
|
|
|
kGs = ctn.KGS,
|
|
|
cbm = ctn.CBM,
|
|
|
tareWeight = ctn.TAREWEIGHT,
|
|
|
contaStatus = ctn.CTNSTATUS,
|
|
|
weighType = ctn.WEIGHTYPE,
|
|
|
weighKGs = ctn.WEIGHKGS,
|
|
|
weighAttn = ctn.WEIGHATTN,
|
|
|
vgmConnCom = ctn.VGMCONNCOM,
|
|
|
weighTel = ctn.WEIGHTEL,
|
|
|
weighDate = ctn.WEIGHDATE,
|
|
|
vgmAddr = ctn.VGMADDR,
|
|
|
vgmEmail = ctn.VGMEMAIL,
|
|
|
remark = ctn.REMARK,
|
|
|
contaCategory = codectn.CTNSIZE == "20" ? "small" : "big"
|
|
|
};
|
|
|
|
|
|
if (OpCtnDetailList != null && OpCtnDetailList.Count > 0) {
|
|
|
|
|
|
newcon.cargoList = new List<CargoList>();
|
|
|
|
|
|
foreach (var detail in OpCtnDetailList) {
|
|
|
var newdetail = new CargoList {
|
|
|
pKGs = detail.PKGS,
|
|
|
kindPKGs = detail.KINDPKGS,
|
|
|
kGs = detail.KGS,
|
|
|
cbm = detail.CBM,
|
|
|
hsCode = detail.HSCODE,
|
|
|
marks = detail.MARKS,
|
|
|
description = detail.DESCRIPTION,
|
|
|
remark = detail.REMARK
|
|
|
};
|
|
|
|
|
|
newcon.cargoList.Add(newdetail);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bi.contaList.Add(newcon);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
result.main.businessInfo = bi;
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 毫秒型时间戳转datetime
|
|
|
/// </summary>
|
|
|
/// <param name="timestamp"></param>
|
|
|
/// <returns></returns>
|
|
|
public static DateTime Timestamp2Datetime(long timestamp) {
|
|
|
|
|
|
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));//当地时区
|
|
|
var time = startTime.AddMilliseconds(timestamp);
|
|
|
return time;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// UrlEncode
|
|
|
/// </summary>
|
|
|
/// <param name="temp">要转码的文本</param>
|
|
|
/// <param name="encoding">编码</param>
|
|
|
/// <returns></returns>
|
|
|
public static string UrlEncode(string temp, Encoding encoding)
|
|
|
{
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
for (int i = 0; i < temp.Length; i++)
|
|
|
{
|
|
|
string t = temp[i].ToString();
|
|
|
string k = HttpUtility.UrlEncode(t, encoding);
|
|
|
if (t == k)
|
|
|
{
|
|
|
stringBuilder.Append(t);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
stringBuilder.Append(k.ToUpper());
|
|
|
}
|
|
|
}
|
|
|
return stringBuilder.ToString();
|
|
|
}
|
|
|
|
|
|
public static void 获取仓储费递增后价格(ref decimal dprice, decimal ADDPRICE, decimal CAPPRICE)
|
|
|
{
|
|
|
if (CAPPRICE != 0)
|
|
|
{
|
|
|
if (dprice < CAPPRICE)
|
|
|
{
|
|
|
dprice += ADDPRICE;
|
|
|
if (CAPPRICE > 0)
|
|
|
{
|
|
|
if (dprice > CAPPRICE)
|
|
|
dprice = CAPPRICE;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dprice = CAPPRICE;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dprice += ADDPRICE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static DBResult CustomerNODR(string CUSTOMERNAME, HttpSessionStateBase Session) {
|
|
|
var result = new DBResult();
|
|
|
var canlogin = BasicDataRefDAL.CheckLogin(Session);
|
|
|
if (!canlogin.Success)
|
|
|
{
|
|
|
return canlogin;
|
|
|
}
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
var custnodr = cdc.V_CUSTOMER_NODR.Where(x => x.CUSTOMERNAME == CUSTOMERNAME).ToList();
|
|
|
if (custnodr == null || custnodr.Count == 0)
|
|
|
{
|
|
|
result.SetErrorInfo("没有找到该客户");
|
|
|
}
|
|
|
else {
|
|
|
result.OK("", custnodr);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
#region asiic码数字转字母
|
|
|
|
|
|
public static string chrtostr(int asciiCode)
|
|
|
{
|
|
|
if (asciiCode >= 0 && asciiCode <= 255)
|
|
|
{
|
|
|
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
|
|
|
byte[] byteArray = new byte[] { (byte)asciiCode };
|
|
|
string strCharacter = asciiEncoding.GetString(byteArray);
|
|
|
return (strCharacter);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
throw new Exception("ASCII Code is not valid.");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 去除非标准乱码
|
|
|
public static string DelOtherWord(string str)
|
|
|
{
|
|
|
//var result = Regex.Replace(str, @"[^0-9a-zA-Z \s~!@#\$%\^&\*\(\)\+=\|\{\}\[:;<,.>\]]", "");
|
|
|
var result = Regex.Replace(str, @"[^0-9a-zA-Z\u4e00-\u9fa5 ~!@#\$%\^&\*\(\)\+=_\-?\|\{\}\[:;<,.>\]/'""\r\n]", "");
|
|
|
//\u4e00-\u9fa5
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region OP_STATUS 增加、更新
|
|
|
|
|
|
public static class OP_STATUSHelper
|
|
|
{
|
|
|
//给一个业务增加一条状态
|
|
|
|
|
|
public static void AddOpStatus(string username, string bsno, string status)
|
|
|
{
|
|
|
var cdc = new Common.DB.CommonDataContext();
|
|
|
|
|
|
var newstatus = new op_status_md(bsno);
|
|
|
newstatus.SetCompStatus(username, status);
|
|
|
cdc.op_status.Add(newstatus);
|
|
|
cdc.SaveChangesAsync();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 重复执行则不会添加
|
|
|
/// </summary>
|
|
|
/// <param name="username"></param>
|
|
|
/// <param name="bsno"></param>
|
|
|
/// <param name="status"></param>
|
|
|
public static void MakeOpStatus(string username, string bsno, string status)
|
|
|
{
|
|
|
var cdc = new Common.DB.CommonDataContext();
|
|
|
|
|
|
var oldstatus = cdc.op_status.Where(x => x.BSNO == bsno && x.STATUS == status && x.ISCOMP == true).ToList();
|
|
|
|
|
|
if (oldstatus == null || oldstatus.Count == 0) {
|
|
|
AddOpStatus(username, bsno, status);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static void DelOpStatus(string username, string bsno, string status)
|
|
|
{
|
|
|
var cdc = new Common.DB.CommonDataContext();
|
|
|
|
|
|
var currstatus = cdc.op_status.Where(x => x.BSNO == bsno && x.STATUS == status).OrderByDescending(o => o.COMPTIME).ToList();
|
|
|
|
|
|
if (currstatus != null && currstatus.Count > 0)
|
|
|
{
|
|
|
var rec = currstatus[0];
|
|
|
rec.ISCOMP = false;
|
|
|
rec.COMPTIME = DateTime.Now;
|
|
|
rec.COMPOP = username;
|
|
|
cdc.op_status.AddOrUpdate(rec);
|
|
|
cdc.SaveChangesAsync();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static void 查验通知(string bsno, string username)
|
|
|
{
|
|
|
MakeOpStatus(username, bsno, "查验通知");
|
|
|
}
|
|
|
|
|
|
///
|
|
|
//public static void del放舱(string username, string bsno)
|
|
|
//{
|
|
|
// DelOpStatus(username, bsno, "已放舱");
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 判断bsno的业务是否已通过特殊放单审批
|
|
|
|
|
|
public static DBResult 特放审批通过(string BSNO) {
|
|
|
var result = new DBResult();
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
var reclist = cdc.v_op_blissuelist_Detail.Where(x => x.bsno == BSNO).ToList();
|
|
|
|
|
|
if (reclist == null || reclist.Count == 0)
|
|
|
{
|
|
|
result.SetErrorInfo("没有进行特放申请");
|
|
|
}
|
|
|
else {
|
|
|
var rec = reclist[0];
|
|
|
if (rec.BLSTATUS == "审核通过")
|
|
|
{
|
|
|
result.OK();
|
|
|
}
|
|
|
else {
|
|
|
result.SetErrorInfo("特放申请未通过");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 枚举类型 值 添加
|
|
|
public static void SaveTsysenumvalue(decimal EnumTypeID, string EnumValueID, string EnumValueName)
|
|
|
{
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
var detailList = cdc.tSysEnumValue.Where(x => x.EnumTypeID == EnumTypeID).ToList();
|
|
|
|
|
|
var needinsert = false;
|
|
|
if (detailList != null && detailList.Count > 0)
|
|
|
{
|
|
|
if (detailList.Exists(x => x.EnumValueID == EnumValueID))
|
|
|
{
|
|
|
needinsert = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
needinsert = true;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
needinsert = true;
|
|
|
}
|
|
|
|
|
|
if (needinsert) {
|
|
|
var newrec = new tSysEnumValue_md();
|
|
|
newrec.EnumTypeID = EnumTypeID;
|
|
|
newrec.EnumValueID = EnumValueID;
|
|
|
newrec.EnumValueName = EnumValueName;
|
|
|
|
|
|
var index = 1;
|
|
|
if (detailList != null && detailList.Count > 0) {
|
|
|
index = detailList.Count + 1;
|
|
|
}
|
|
|
|
|
|
newrec.DispIndex = index;
|
|
|
|
|
|
cdc.tSysEnumValue.Add(newrec);
|
|
|
cdc.SaveChanges();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 枚举类型83000 综合业务的装货港卸货港 新增
|
|
|
|
|
|
public static DBResult SaveOtherPort(string PORT) {
|
|
|
var result = new DBResult();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
SaveTsysenumvalue(83000, PORT, PORT);
|
|
|
result.OK("保存成功");
|
|
|
} catch (Exception e) {
|
|
|
result.SetErrorInfo(e.Message);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
public static bool 具有webconfig公司代码(string code)
|
|
|
{
|
|
|
if (ConfigurationManager.AppSettings["COMPANYCODE"] != null)
|
|
|
{
|
|
|
if (ConfigurationManager.AppSettings["COMPANYCODE"] == code)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
public static bool 具有webconfig公司代码(List<string> codeList)
|
|
|
{
|
|
|
if (ConfigurationManager.AppSettings["COMPANYCODE"] != null)
|
|
|
{
|
|
|
foreach (var item in codeList) {
|
|
|
if (具有webconfig公司代码(item)) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 压缩
|
|
|
/// </summary>
|
|
|
/// <param name="input"></param>
|
|
|
/// <returns></returns>
|
|
|
public static string Compress(string input)
|
|
|
{
|
|
|
string result = string.Empty;
|
|
|
byte[] buffer = Encoding.UTF8.GetBytes(input);
|
|
|
using (MemoryStream outputStream = new MemoryStream())
|
|
|
{
|
|
|
using (BZip2OutputStream zipStream = new BZip2OutputStream(outputStream))
|
|
|
{
|
|
|
zipStream.Write(buffer, 0, buffer.Length);
|
|
|
zipStream.Close();
|
|
|
}
|
|
|
return Convert.ToBase64String(outputStream.ToArray());
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 解压缩
|
|
|
/// </summary>
|
|
|
/// <param name="input"></param>
|
|
|
/// <returns></returns>
|
|
|
public static string Decompress(string input)
|
|
|
{
|
|
|
string result = string.Empty;
|
|
|
byte[] buffer = Convert.FromBase64String(input);
|
|
|
using (Stream inputStream = new MemoryStream(buffer))
|
|
|
{
|
|
|
BZip2InputStream zipStream = new BZip2InputStream(inputStream);
|
|
|
|
|
|
using (StreamReader reader = new StreamReader(zipStream, Encoding.UTF8))
|
|
|
{
|
|
|
//输出
|
|
|
result = reader.ReadToEnd();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public class BarCodeDrawing
|
|
|
{
|
|
|
private Hashtable m_BarCodeDrawing = new Hashtable();
|
|
|
|
|
|
private byte m_Magnify = 0;
|
|
|
/// <summary>
|
|
|
/// 放大倍数
|
|
|
/// </summary>
|
|
|
public byte Magnify { get { return m_Magnify; } set { m_Magnify = value; } }
|
|
|
|
|
|
private int m_Height = 40;
|
|
|
/// <summary>
|
|
|
/// 图形高
|
|
|
/// </summary>
|
|
|
public int Height { get { return m_Height; } set { m_Height = value; } }
|
|
|
|
|
|
private System.Drawing.Font m_ViewFont = null;
|
|
|
/// <summary>
|
|
|
/// 字体大小
|
|
|
/// </summary>
|
|
|
public System.Drawing.Font ViewFont { get { return m_ViewFont; } set { m_ViewFont = value; } }
|
|
|
|
|
|
|
|
|
|
|
|
public BarCodeDrawing()
|
|
|
{
|
|
|
|
|
|
m_BarCodeDrawing.Add("A", "1101010010110");
|
|
|
m_BarCodeDrawing.Add("B", "1011010010110");
|
|
|
m_BarCodeDrawing.Add("C", "1101101001010");
|
|
|
m_BarCodeDrawing.Add("D", "1010110010110");
|
|
|
m_BarCodeDrawing.Add("E", "1101011001010");
|
|
|
m_BarCodeDrawing.Add("F", "1011011001010");
|
|
|
m_BarCodeDrawing.Add("G", "1010100110110");
|
|
|
m_BarCodeDrawing.Add("H", "1101010011010");
|
|
|
m_BarCodeDrawing.Add("I", "1011010011010");
|
|
|
m_BarCodeDrawing.Add("J", "1010110011010");
|
|
|
m_BarCodeDrawing.Add("K", "1101010100110");
|
|
|
m_BarCodeDrawing.Add("L", "1011010100110");
|
|
|
m_BarCodeDrawing.Add("M", "1101101010010");
|
|
|
m_BarCodeDrawing.Add("N", "1010110100110");
|
|
|
m_BarCodeDrawing.Add("O", "1101011010010");
|
|
|
m_BarCodeDrawing.Add("P", "1011011010010");
|
|
|
m_BarCodeDrawing.Add("Q", "1010101100110");
|
|
|
m_BarCodeDrawing.Add("R", "1101010110010");
|
|
|
m_BarCodeDrawing.Add("S", "1011010110010");
|
|
|
m_BarCodeDrawing.Add("T", "1010110110010");
|
|
|
m_BarCodeDrawing.Add("U", "1100101010110");
|
|
|
m_BarCodeDrawing.Add("V", "1001101010110");
|
|
|
m_BarCodeDrawing.Add("W", "1100110101010");
|
|
|
m_BarCodeDrawing.Add("X", "1001011010110");
|
|
|
m_BarCodeDrawing.Add("Y", "1100101101010");
|
|
|
m_BarCodeDrawing.Add("Z", "1001101101010");
|
|
|
m_BarCodeDrawing.Add("0", "1010011011010");
|
|
|
m_BarCodeDrawing.Add("1", "1101001010110");
|
|
|
m_BarCodeDrawing.Add("2", "1011001010110");
|
|
|
m_BarCodeDrawing.Add("3", "1101100101010");
|
|
|
m_BarCodeDrawing.Add("4", "1010011010110");
|
|
|
m_BarCodeDrawing.Add("5", "1101001101010");
|
|
|
m_BarCodeDrawing.Add("6", "1011001101010");
|
|
|
m_BarCodeDrawing.Add("7", "1010010110110");
|
|
|
m_BarCodeDrawing.Add("8", "1101001011010");
|
|
|
m_BarCodeDrawing.Add("9", "1011001011010");
|
|
|
m_BarCodeDrawing.Add("+", "1001010010010");
|
|
|
m_BarCodeDrawing.Add("-", "1001010110110");
|
|
|
m_BarCodeDrawing.Add("*", "1001011011010");
|
|
|
m_BarCodeDrawing.Add("/", "1001001010010");
|
|
|
m_BarCodeDrawing.Add("%", "1010010010010");
|
|
|
m_BarCodeDrawing.Add("contentquot", "1001001001010");
|
|
|
m_BarCodeDrawing.Add(".", "1100101011010");
|
|
|
m_BarCodeDrawing.Add(" ", "1001101011010");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
public enum BarCodeDrawingModel
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 基本类别 1234567890ABC
|
|
|
/// </summary>
|
|
|
BarCodeDrawingNormal,
|
|
|
/// <summary>
|
|
|
/// 全ASCII方式 +A+B 来表示小写
|
|
|
/// </summary>
|
|
|
BarCodeDrawingFullAscII
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获得条码图形
|
|
|
/// </summary>
|
|
|
/// <param name="p_Text">文字信息</param>
|
|
|
/// <param name="p_Model">类别</param>
|
|
|
/// <param name="p_StarChar">是否增加前后*号</param>
|
|
|
/// <returns>图形</returns>
|
|
|
public Bitmap GetCodeImage(string p_Text, BarCodeDrawingModel p_Model, bool p_StarChar)
|
|
|
{
|
|
|
string _ValueText = "";
|
|
|
string _CodeText = "";
|
|
|
char[] _ValueChar = null;
|
|
|
switch (p_Model)
|
|
|
{
|
|
|
case BarCodeDrawingModel.BarCodeDrawingNormal:
|
|
|
_ValueText = p_Text.ToUpper();
|
|
|
break;
|
|
|
default:
|
|
|
_ValueChar = p_Text.ToCharArray();
|
|
|
for (int i = 0; i != _ValueChar.Length; i++)
|
|
|
{
|
|
|
if ((int)_ValueChar[i] >= 97 && (int)_ValueChar[i] <= 122)
|
|
|
{
|
|
|
_ValueText += "+" + _ValueChar[i].ToString().ToUpper();
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_ValueText += _ValueChar[i].ToString();
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
_ValueChar = _ValueText.ToCharArray();
|
|
|
|
|
|
if (p_StarChar == true) _CodeText += m_BarCodeDrawing["*"];
|
|
|
|
|
|
for (int i = 0; i != _ValueChar.Length; i++)
|
|
|
{
|
|
|
if (p_StarChar == true && _ValueChar[i] == '*') throw new Exception("带有起始符号不能出现*");
|
|
|
|
|
|
object _CharCode = m_BarCodeDrawing[_ValueChar[i].ToString()];
|
|
|
if (_CharCode == null) throw new Exception("不可用的字符" + _ValueChar[i].ToString());
|
|
|
_CodeText += _CharCode.ToString();
|
|
|
}
|
|
|
|
|
|
|
|
|
if (p_StarChar == true) _CodeText += m_BarCodeDrawing["*"];
|
|
|
|
|
|
|
|
|
Bitmap _CodeBmp = GetImage(_CodeText);
|
|
|
GetViewImage(_CodeBmp, p_Text);
|
|
|
return _CodeBmp;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 绘制编码图形
|
|
|
/// </summary>
|
|
|
/// <param name="p_Text">编码</param>
|
|
|
/// <returns>图形</returns>
|
|
|
private Bitmap GetImage(string p_Text)
|
|
|
{
|
|
|
char[] _Value = p_Text.ToCharArray();
|
|
|
|
|
|
|
|
|
//宽 == 需要绘制的数量*放大倍数 + 两个字的宽
|
|
|
Bitmap _CodeImage = new Bitmap(_Value.Length * ((int)m_Magnify + 1), (int)m_Height);
|
|
|
Graphics _Garphics = Graphics.FromImage(_CodeImage);
|
|
|
|
|
|
_Garphics.FillRectangle(Brushes.White, new Rectangle(0, 0, _CodeImage.Width, _CodeImage.Height));
|
|
|
|
|
|
int _LenEx = 0;
|
|
|
for (int i = 0; i != _Value.Length; i++)
|
|
|
{
|
|
|
int _DrawWidth = m_Magnify + 1;
|
|
|
if (_Value[i] == '1')
|
|
|
{
|
|
|
_Garphics.FillRectangle(Brushes.Black, new Rectangle(_LenEx, 0, _DrawWidth, m_Height));
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_Garphics.FillRectangle(Brushes.White, new Rectangle(_LenEx, 0, _DrawWidth, m_Height));
|
|
|
}
|
|
|
_LenEx += _DrawWidth;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_Garphics.Dispose();
|
|
|
return _CodeImage;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 绘制文字
|
|
|
/// </summary>
|
|
|
/// <param name="p_CodeImage">图形</param>
|
|
|
/// <param name="p_Text">文字</param>
|
|
|
private void GetViewImage(Bitmap p_CodeImage, string p_Text)
|
|
|
{
|
|
|
if (m_ViewFont == null) return;
|
|
|
Graphics _Graphics = Graphics.FromImage(p_CodeImage);
|
|
|
SizeF _FontSize = _Graphics.MeasureString(p_Text, m_ViewFont);
|
|
|
|
|
|
if (_FontSize.Width > p_CodeImage.Width || _FontSize.Height > p_CodeImage.Height - 20)
|
|
|
{
|
|
|
_Graphics.Dispose();
|
|
|
return;
|
|
|
}
|
|
|
int _StarHeight = p_CodeImage.Height - (int)_FontSize.Height;
|
|
|
|
|
|
_Graphics.FillRectangle(Brushes.White, new Rectangle(0, _StarHeight, p_CodeImage.Width, (int)_FontSize.Height));
|
|
|
|
|
|
int _StarWidth = (p_CodeImage.Width - (int)_FontSize.Width) / 2;
|
|
|
|
|
|
_Graphics.DrawString(p_Text, m_ViewFont, Brushes.Black, _StarWidth, _StarHeight);
|
|
|
|
|
|
_Graphics.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} |