|
|
using System;
|
|
|
using System.Data;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text;
|
|
|
using DSWeb.MvcShipping.Models.MsCrmQuotation;
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
using DSWeb.EntityDA;
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
using HcUtility.Comm;
|
|
|
using System.Data.SqlClient;
|
|
|
using DSWeb.DataAccess;
|
|
|
using DSWeb.MvcShipping.Models.MsCodeServiceFeeTemplate;
|
|
|
using DSWeb.MvcShipping.DAL.MsCodeServiceFeeTemplateDAL;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsCrmQuotationDAL
|
|
|
{
|
|
|
public class MsCrmQuotationDAL
|
|
|
{
|
|
|
#region 查询
|
|
|
static public List<MsCrmQuotationEntity> GetDataList(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
|
{
|
|
|
var rangstr = GetRangStr("index", userid, usercode, companyid);
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
String strSql = "SELECT *"
|
|
|
+ ",RMBHJ=isnull((select sum(UNITPRICE) as RMBHJ from crm_quotation_detail where CURRENCY='RMB' and LINKGID=crm_quotation.GID),0)"//需求编号:SR2017071700006-2、3、4
|
|
|
+ ",USDHJ=isnull((select sum(USDHJ) as USDHJ from crm_quotation_detail where CURRENCY<>'RMB' and LINKGID=crm_quotation.GID),0)"//需求编号:SR2017071700006-2、3、4
|
|
|
+ " from crm_quotation";
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql += " where " + strCondition;
|
|
|
}
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql += " order by " + sortstring;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql += " order by MODIFIEDTIME desc";
|
|
|
}
|
|
|
return SetData(strSql);
|
|
|
}
|
|
|
|
|
|
static public MsCrmQuotationEntity GetData(string condition, string userid, string usercode, string companyid)
|
|
|
{
|
|
|
var rangstr = GetRangStr("index", userid, usercode, companyid);
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
String strSql = "SELECT *"
|
|
|
+ ",RMBHJ=isnull((select sum(UNITPRICE) as RMBHJ from crm_quotation_detail where CURRENCY='RMB' and LINKGID=crm_quotation.GID),0)"//需求编号:SR2017071700006-2、3、4
|
|
|
+ ",USDHJ=isnull((select sum(USDHJ) as USDHJ from crm_quotation_detail where CURRENCY<>'RMB' and LINKGID=crm_quotation.GID),0)"//需求编号:SR2017071700006-2、3、4
|
|
|
+ " from crm_quotation";
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql += " where " + condition;
|
|
|
}
|
|
|
var list=SetData(strSql);
|
|
|
if (list.Count > 0)
|
|
|
{
|
|
|
return list[0];
|
|
|
}
|
|
|
return new MsCrmQuotationEntity();
|
|
|
}
|
|
|
|
|
|
private static List<MsCrmQuotationEntity> SetData(String strSql)
|
|
|
{
|
|
|
var headList = new List<MsCrmQuotationEntity>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsCrmQuotationEntity data = new MsCrmQuotationEntity();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//惟一值
|
|
|
data.CLIENTGID = (reader["CLIENTGID"] == null ? "" : Convert.ToString(reader["CLIENTGID"]));//相关联的潜在客户GID
|
|
|
data.SHORTNAME = (reader["SHORTNAME"] == null ? "" : Convert.ToString(reader["SHORTNAME"]));//客户简称
|
|
|
data.DESCRIPTION = (reader["DESCRIPTION"] == null ? "" : Convert.ToString(reader["DESCRIPTION"]));//客户全称
|
|
|
data.SALE = (reader["SALE"] == null ? "" : Convert.ToString(reader["SALE"]));//销售
|
|
|
if (reader["QUOTATIONDATE"] != null && reader["QUOTATIONDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["QUOTATIONDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["QUOTATIONDATE"].ToString().Trim() != "")
|
|
|
{
|
|
|
data.QUOTATIONDATE = Convert.ToDateTime(reader["QUOTATIONDATE"]);//报价日期
|
|
|
}
|
|
|
data.CORPID = (reader["CORPID"] == null ? "" : Convert.ToString(reader["CORPID"]));//所属分公司代码
|
|
|
data.PORTLOAD = (reader["PORTLOAD"] == null ? "" : Convert.ToString(reader["PORTLOAD"]));//起运港(默认青岛)
|
|
|
data.PORTDISCHARGE = (reader["PORTDISCHARGE"] == null ? "" : Convert.ToString(reader["PORTDISCHARGE"]));//目的港
|
|
|
data.LANE = (reader["LANE"] == null ? "" : Convert.ToString(reader["LANE"]));//航线
|
|
|
data.CARRIER = (reader["CARRIER"] == null ? "" : Convert.ToString(reader["CARRIER"]));//船公司
|
|
|
if (reader["ETD"] != null && reader["ETD"].ToString().Trim().IndexOf("0001") < 0 && reader["ETD"].ToString().Trim().IndexOf("1900") < 0 && reader["ETD"].ToString().Trim() != "")
|
|
|
{
|
|
|
data.ETD = Convert.ToDateTime(reader["ETD"]);//开船日期
|
|
|
}
|
|
|
data.ENTREPORT = (reader["ENTREPORT"] == null ? "" : Convert.ToString(reader["ENTREPORT"]));//中转港
|
|
|
data.TT = (reader["TT"] == null ? "" : Convert.ToString(reader["TT"]));//航程
|
|
|
data.GOODSNAME = (reader["GOODSNAME"] == null ? "" : Convert.ToString(reader["GOODSNAME"]));//品名
|
|
|
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//备注
|
|
|
data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//创建人
|
|
|
if (reader["CREATETIME"] != null && reader["CREATETIME"].ToString().Trim().IndexOf("0001") < 0 && reader["CREATETIME"].ToString().Trim().IndexOf("1900") < 0 && reader["CREATETIME"].ToString().Trim() != "")
|
|
|
{
|
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);//创建时间
|
|
|
}
|
|
|
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//最后一次更新操作人
|
|
|
if (reader["MODIFIEDTIME"] != null && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["MODIFIEDTIME"].ToString().Trim() != "")
|
|
|
{
|
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//最后一次更新操作时间
|
|
|
}
|
|
|
data.CONTACTNAME = (reader["CONTACTNAME"] == null ? "" : Convert.ToString(reader["CONTACTNAME"]));//CONTACTNAME
|
|
|
if (reader["VALIDDATE"] != null && reader["VALIDDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["VALIDDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["VALIDDATE"].ToString().Trim() != "")
|
|
|
{
|
|
|
data.VALIDDATE = Convert.ToDateTime(reader["VALIDDATE"]);//有效期
|
|
|
}
|
|
|
data.WEEK = (reader["WEEK"] == null ? "" : Convert.ToString(reader["WEEK"]));//WEEK
|
|
|
data.QUOTATIONCODE = (reader["QUOTATIONCODE"] == null ? "" : Convert.ToString(reader["QUOTATIONCODE"]));//报价编号
|
|
|
data.TEL = (reader["TEL"] == null ? "" : Convert.ToString(reader["TEL"]));//联系方式
|
|
|
data.EMAIL = (reader["EMAIL"] == null ? "" : Convert.ToString(reader["EMAIL"]));//邮箱
|
|
|
data.CTNCODE = (reader["CTNCODE"] == null ? "" : Convert.ToString(reader["CTNCODE"]));//箱型
|
|
|
data.CTNNUM = (reader["CTNNUM"] == null ? 0 : Convert.ToInt32(reader["CTNNUM"]));//箱量
|
|
|
data.GOODSTYPE = (reader["GOODSTYPE"] == null ? "" : Convert.ToString(reader["GOODSTYPE"]));//产品类别
|
|
|
data.SERVICE = (reader["SERVICE"] == null ? "" : Convert.ToString(reader["SERVICE"]));//运输条款
|
|
|
data.CTNSTATUS = (reader["CTNSTATUS"] == null ? "" : Convert.ToString(reader["CTNSTATUS"]));//箱状态
|
|
|
data.FORWARDER = (reader["FORWARDER"] == null ? "" : Convert.ToString(reader["FORWARDER"]));//使用代理
|
|
|
data.COMMISSIONRATE = (reader["COMMISSIONRATE"] == null ? 0 : Convert.ToDecimal(reader["COMMISSIONRATE"]));//佣金比率
|
|
|
data.FBPPORTLOAD = (reader["FBPPORTLOAD"] == null ? 0 : Convert.ToInt32(reader["FBPPORTLOAD"]));//起运港免箱天数
|
|
|
data.CQPORTLOAD = (reader["CQPORTLOAD"] == null ? "" : Convert.ToString(reader["CQPORTLOAD"]));//起运港超期标准
|
|
|
data.FBPPORTDISCHARGE = (reader["FBPPORTDISCHARGE"] == null ? 0 : Convert.ToInt32(reader["FBPPORTDISCHARGE"]));//目的港免箱天数
|
|
|
data.CQPORTDISCHARGE = (reader["CQPORTDISCHARGE"] == null ? "" : Convert.ToString(reader["CQPORTDISCHARGE"]));//目的港超期标准
|
|
|
data.RMBHJ = (reader["RMBHJ"] == null ? 0 : Convert.ToDecimal(reader["RMBHJ"]));//需求编号:SR2017071700006-2、3、4
|
|
|
data.USDHJ = (reader["USDHJ"] == null ? 0 : Convert.ToDecimal(reader["USDHJ"]));//需求编号:SR2017071700006-2、3、4
|
|
|
data.UNNO = (reader["UNNO"] == null ? "" : Convert.ToString(reader["UNNO"]));//UN//需求编号:SR2017080400003
|
|
|
data.DCLASS = (reader["DCLASS"] == null ? "" : Convert.ToString(reader["DCLASS"]));//危险品等级//需求编号:SR2017080400003
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 打印
|
|
|
static public string GetDataListStr(string strCondition, string gids, string userid, string usercode, string companyid, string sort = null)
|
|
|
{
|
|
|
String strSql = "SELECT *"
|
|
|
+ ",RMBHJ=isnull((select sum(UNITPRICE) as RMBHJ from crm_quotation_detail where CURRENCY='RMB' and LINKGID=crm_quotation.GID),0)"//需求编号:SR2017071700006-2、3、4
|
|
|
+ ",USDHJ=isnull((select sum(USDHJ) as USDHJ from crm_quotation_detail where CURRENCY<>'RMB' and LINKGID=crm_quotation.GID),0)"//需求编号:SR2017071700006-2、3、4
|
|
|
+ " from crm_quotation where 1=1";
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql += " and " + strCondition;
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(gids))
|
|
|
{
|
|
|
strSql += " and gid in ('" + gids.Replace(",", "','") + "')";
|
|
|
}
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql += " order by " + sortstring;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql += " order by MODIFIEDTIME desc";
|
|
|
}
|
|
|
return strSql.ToString();
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 查询明细表
|
|
|
static public List<CrmQuotationDetailEntity> GetDetailList(string strCondition, string userid, string usercode, string companyid)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT *,RMBHJ=(case when CURRENCY='RMB' then UNITPRICE else 0 end) from crm_quotation_detail WITH(NOLOCK) where 1=1");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" order by [CREATETIME]");
|
|
|
return SetDetail(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<CrmQuotationDetailEntity> SetDetail(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CrmQuotationDetailEntity>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CrmQuotationDetailEntity data = new CrmQuotationDetailEntity();
|
|
|
#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.FEETYPE = (reader["FEETYPE"] == null ? "" : Convert.ToString(reader["FEETYPE"]));//费用类型
|
|
|
data.FEENAME = (reader["FEENAME"] == null ? "" : Convert.ToString(reader["FEENAME"]));//费用中文名称
|
|
|
data.UNIT = (reader["UNIT"] == null ? "" : Convert.ToString(reader["UNIT"]));//单位标准
|
|
|
data.UNITPRICE = (reader["UNITPRICE"] == null ? 0 : Convert.ToDecimal(reader["UNITPRICE"]));//单价
|
|
|
data.CURRENCY = (reader["CURRENCY"] == null ? "" : Convert.ToString(reader["CURRENCY"]));//币别
|
|
|
data.CARRIER = (reader["CARRIER"] == null ? "" : Convert.ToString(reader["CARRIER"]));//船公司
|
|
|
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//备注
|
|
|
data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//创建人
|
|
|
if (reader["CREATETIME"] != null && reader["CREATETIME"].ToString().Trim().IndexOf("0001") < 0 && reader["CREATETIME"].ToString().Trim().IndexOf("1900") < 0 && reader["CREATETIME"].ToString().Trim() != "")
|
|
|
{
|
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);//创建时间
|
|
|
}
|
|
|
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//最后一次更新操作人
|
|
|
if (reader["MODIFIEDTIME"] != null && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["MODIFIEDTIME"].ToString().Trim() != "")
|
|
|
{
|
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//最后一次更新操作时间
|
|
|
}
|
|
|
data.USDHJ = (reader["USDHJ"] == null ? 0 : Convert.ToDecimal(reader["USDHJ"]));//需求编号:SR2017071700006-2、3、4
|
|
|
data.RMBHJ = (reader["RMBHJ"] == null ? 0 : Convert.ToDecimal(reader["RMBHJ"]));//需求编号:SR2017071700006-2、3、4
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
reader.Dispose();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public CrmQuotationDetailEntity GetDataDetail(string condition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT *,RMBHJ=(case when CURRENCY='RMB' then UNITPRICE else 0 end) from crm_quotation_detail WITH(NOLOCK) where 1=1");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" and " + condition);
|
|
|
}
|
|
|
strSql.Append(" order by [CREATETIME]");
|
|
|
var list = SetDetail(strSql);
|
|
|
if (list.Count > 0)
|
|
|
{
|
|
|
return list[0];
|
|
|
}
|
|
|
return new CrmQuotationDetailEntity();
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 提取规则编号 getCodeRuleWmsOut
|
|
|
/// <summary>
|
|
|
/// 提取规则编号
|
|
|
/// </summary>
|
|
|
/// OutBsno = getCodeRuleWmsOut("出库单号", "BSNO");
|
|
|
/// <param name="strRULENAME">规则项目名称</param>
|
|
|
/// <param name="strfield">需要加规则的字段</param>
|
|
|
/// <param name="iCount">需要添加的行数</param>
|
|
|
/// <returns></returns>
|
|
|
static public String getCodeRuleWmsOut(string strRULENAME, string strfield, int iCount, string strUserID, string strCompanyID)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
|
|
//调用编码规则
|
|
|
string strRULEYEAR = "";
|
|
|
string strRULECONTENT = "";
|
|
|
string strCODENAME = "";
|
|
|
string strDEPTNO = "";
|
|
|
string strRULENOLENGTH = "";
|
|
|
int iRULENOLENGTH = 0;
|
|
|
int inum = 0;
|
|
|
string strCONTENT = "";
|
|
|
DataSet ds = T_ALL_DA.GetAllSQL("select *,getdate() DODATE from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=9");
|
|
|
if (ds != null)
|
|
|
{
|
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
getCodeRuleEnabled(strRULENAME, strfield);
|
|
|
//
|
|
|
if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["DODATE"].ToString().Trim() == "")
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
DateTime dETD = System.Convert.ToDateTime(ds.Tables[0].Rows[0]["DODATE"].ToString().Trim());
|
|
|
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR = dETD.ToString("yyyy") + dETD.ToString("MM");
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR = dETD.ToString("yy") + dETD.ToString("MM");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR = dETD.ToString("yyyy");
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR = dETD.ToString("yy");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份"))
|
|
|
{
|
|
|
DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()"));
|
|
|
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR = fwqdate.ToString("yyyy") + fwqdate.ToString("MM");
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR = fwqdate.ToString("yy") + fwqdate.ToString("MM");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR = fwqdate.ToString("yyyy");
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR = fwqdate.ToString("yy");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
if (ds.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
strCODENAME = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + strUserID + "')");
|
|
|
}
|
|
|
if (ds.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
strDEPTNO = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + strUserID + "')");
|
|
|
}
|
|
|
strRULECONTENT = ds.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
|
|
|
strRULECONTENT = strRULECONTENT.Replace("《COMPANY》", strCODENAME);
|
|
|
strRULECONTENT = strRULECONTENT.Replace("《DEPT》", strDEPTNO);
|
|
|
//
|
|
|
if (ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim() == "")
|
|
|
{
|
|
|
iRULENOLENGTH = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iRULENOLENGTH = int.Parse(ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim());
|
|
|
}
|
|
|
strCONTENT = strRULECONTENT + strRULEYEAR;
|
|
|
//获取分公司的票号头字符
|
|
|
string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
|
|
|
strCONTENT = tempBANKSHEAD + strCONTENT;
|
|
|
//
|
|
|
strRULENOLENGTH = T_ALL_DA.GetStrSQL(strfield, "select top 1 " + strfield + " from [crm_quotation] where " + strfield + " like '" + strCONTENT.Trim() + "%' order by " + strfield + " DESC");
|
|
|
if (strRULENOLENGTH == "")
|
|
|
{
|
|
|
strRULENOLENGTH = "1";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strRULENOLENGTH = strRULENOLENGTH.Replace(strCONTENT.Trim(), "");
|
|
|
inum = int.Parse(strRULENOLENGTH.Trim());
|
|
|
inum = inum + iCount;
|
|
|
strRULENOLENGTH = inum.ToString();
|
|
|
}
|
|
|
int j = iRULENOLENGTH - strRULENOLENGTH.Length;
|
|
|
for (int i = 1; i <= j; i++)
|
|
|
{
|
|
|
strRULENOLENGTH = "0" + strRULENOLENGTH;
|
|
|
}
|
|
|
//
|
|
|
strCONTENT = strCONTENT + strRULENOLENGTH;
|
|
|
return strCONTENT;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 规则编号_是否生成之后允许编辑 getCodeRuleEnabled
|
|
|
/// <summary>
|
|
|
/// 规则编号_是否生成之后允许编辑
|
|
|
/// </summary>
|
|
|
/// <param name="strRULENAME">规则项目名称</param>
|
|
|
/// <param name="strfield">需要加规则的字段</param>
|
|
|
/// <returns></returns>
|
|
|
static public Boolean getCodeRuleEnabled(string strRULENAME, string strfield)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
bool blRule = false;
|
|
|
//是否生成之后允许编辑
|
|
|
DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=9");
|
|
|
if (ds != null)
|
|
|
{
|
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
if (strfield == "BSNO")
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["ISALLOWEDITS"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
blRule = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
blRule = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return blRule;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 生成编码
|
|
|
public static String getCodeRule(string strRULENAME, int strRULETYPE, string strfield, string strETD, string strACCDATE, string strUserID, string strCompanyID)
|
|
|
{
|
|
|
//调用编码规则
|
|
|
if (strETD.Trim().IndexOf("0001") > -1)
|
|
|
{
|
|
|
strETD = "";
|
|
|
}
|
|
|
string strRULEYEAR = "";
|
|
|
string strRULECONTENT = "";
|
|
|
string strCODENAME = "";
|
|
|
string strDEPTNO = "";
|
|
|
string strRULENOLENGTH = "";
|
|
|
int iRULENOLENGTH = 0;
|
|
|
int inum = 0;
|
|
|
string strCONTENT = "";
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
//
|
|
|
DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=" + strRULETYPE);
|
|
|
if (ds != null)
|
|
|
{
|
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
|
|
|
{
|
|
|
if (strETD.Trim() == "")
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
DateTime dETD = System.Convert.ToDateTime(strETD.Trim());
|
|
|
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR = dETD.ToString("yyyy") + dETD.ToString("MM");
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR = dETD.ToString("yy") + dETD.ToString("MM");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR = dETD.ToString("yyyy");
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR = dETD.ToString("yy");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("会计期间"))
|
|
|
{
|
|
|
if (strACCDATE.Trim() == "")
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
DateTime dACCDATE = System.Convert.ToDateTime(strACCDATE.Trim() + "-01");
|
|
|
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR = dACCDATE.ToString("yyyy") + dACCDATE.ToString("MM");
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR = dACCDATE.ToString("yy") + dACCDATE.ToString("MM");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR = dACCDATE.ToString("yyyy");
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR = dACCDATE.ToString("yy");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份"))
|
|
|
{
|
|
|
DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()"));
|
|
|
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR = fwqdate.ToString("yyyy") + fwqdate.ToString("MM");
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR = fwqdate.ToString("yy") + fwqdate.ToString("MM");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR = fwqdate.ToString("yyyy");
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR = fwqdate.ToString("yy");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
if (ds.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
strCODENAME = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + strUserID.Trim() + "')");
|
|
|
}
|
|
|
if (ds.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
strDEPTNO = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + strUserID.Trim() + "')");
|
|
|
}
|
|
|
strRULECONTENT = ds.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
|
|
|
strRULECONTENT = strRULECONTENT.Replace("《COMPANY》", strCODENAME);
|
|
|
strRULECONTENT = strRULECONTENT.Replace("《DEPT》", strDEPTNO);
|
|
|
//
|
|
|
iRULENOLENGTH = int.Parse(ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim());
|
|
|
strCONTENT = strRULECONTENT + strRULEYEAR;
|
|
|
//获取分公司的票号头字符
|
|
|
string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
|
|
|
strCONTENT = tempBANKSHEAD + strCONTENT;
|
|
|
//
|
|
|
strRULENOLENGTH = T_ALL_DA.GetStrSQL(strfield, "select top 1 " + strfield + " from [op_other] where " + strfield + " like '" + strCONTENT.Trim() + "%' order by " + strfield + " DESC");
|
|
|
if (strRULENOLENGTH == "")
|
|
|
{
|
|
|
strRULENOLENGTH = "1";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strRULENOLENGTH = strRULENOLENGTH.Replace(strCONTENT.Trim(), "");
|
|
|
inum = int.Parse(strRULENOLENGTH.Trim());
|
|
|
inum = inum + 1;
|
|
|
strRULENOLENGTH = inum.ToString();
|
|
|
}
|
|
|
int j = iRULENOLENGTH - strRULENOLENGTH.Length;
|
|
|
for (int i = 1; i <= j; i++)
|
|
|
{
|
|
|
strRULENOLENGTH = "0" + strRULENOLENGTH;
|
|
|
}
|
|
|
//
|
|
|
strCONTENT = strCONTENT + strRULENOLENGTH;
|
|
|
return strCONTENT;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 判断编码是否有重复
|
|
|
static public int GetRdCount(string strCondition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append(" Count(BSNO) AS CT ");
|
|
|
strSql.Append(" from op_other ");
|
|
|
if (strCondition.Trim() != String.Empty)
|
|
|
{
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
}
|
|
|
var ct=0;
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
|
|
|
ct = Convert.ToInt16(reader["CT"]);
|
|
|
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return ct;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 判断是否有FEE
|
|
|
public static bool GetFeeCount(string sGID)
|
|
|
{
|
|
|
var isfee = false;
|
|
|
String strSql = "Select count(*) as count from crm_quotation_detail where LINKGID in ('" + sGID.Replace(",","','") + "')";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
var evData = Convert.ToInt32(reader["count"]);
|
|
|
if (evData > 0) { isfee = true; };
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return isfee;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 删除
|
|
|
public static DBResult Delete(string gids)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
try
|
|
|
{
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete from [crm_quotation] where GID in ('" + gids.Replace(",", "','") + "')");
|
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
result.Success = false;
|
|
|
result.Message = "删除出现错误,请重试!";
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
result.Success = true;
|
|
|
result.Message = "操作成功";
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 删除明细
|
|
|
public static DBResult DeleteDetail(string gids)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (var conn = db.CreateConnection())
|
|
|
{
|
|
|
conn.Open();
|
|
|
var tran = conn.BeginTransaction();
|
|
|
try
|
|
|
{
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete from [crm_quotation_detail] where GID in ('" + gids.Replace(",", "','") + "')");
|
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
tran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
tran.Rollback();
|
|
|
result.Success = false;
|
|
|
result.Message = "删除出现错误,请重试!";
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
result.Success = true;
|
|
|
result.Message = "操作成功";
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 品名code_msds _下拉框//需求编号:SR2017072600008-1
|
|
|
static public List<CodeMsdsEntity> GetCodeMsdsList()
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT *,CodeAndName=(CHEMICALCGOODSNAME+' | '+GOODNAME) FROM code_msds order by [GOODNAME]");
|
|
|
return SetCodeMsds(strSql, true);
|
|
|
}
|
|
|
|
|
|
private static List<CodeMsdsEntity> SetCodeMsds(StringBuilder strSql, bool isNull)
|
|
|
{
|
|
|
var headList = new List<CodeMsdsEntity>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CodeMsdsEntity data = new CodeMsdsEntity();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//GID
|
|
|
data.GOODNAME = (reader["GOODNAME"] == null ? "" : Convert.ToString(reader["GOODNAME"]));//GOODNAME
|
|
|
data.TRADEGOODSNAME = (reader["TRADEGOODSNAME"] == null ? "" : Convert.ToString(reader["TRADEGOODSNAME"]));//TRADEGOODSNAME
|
|
|
data.CHEMICALGOODSNAME = (reader["CHEMICALGOODSNAME"] == null ? "" : Convert.ToString(reader["CHEMICALGOODSNAME"]));//CHEMICALGOODSNAME
|
|
|
data.CHEMICALCGOODSNAME = (reader["CHEMICALCGOODSNAME"] == null ? "" : Convert.ToString(reader["CHEMICALCGOODSNAME"]));//CHEMICALCGOODSNAME
|
|
|
data.CASNO = (reader["CASNO"] == null ? "" : Convert.ToString(reader["CASNO"]));//CASNO
|
|
|
data.UNNO = (reader["UNNO"] == null ? "" : Convert.ToString(reader["UNNO"]));//UNNO
|
|
|
data.DCLASS = (reader["DCLASS"] == null ? "" : Convert.ToString(reader["DCLASS"]));//DCLASS
|
|
|
data.SDCLASS = (reader["SDCLASS"] == null ? "" : Convert.ToString(reader["SDCLASS"]));//SDCLASS
|
|
|
data.PACKINGGROUP = (reader["PACKINGGROUP"] == null ? "" : Convert.ToString(reader["PACKINGGROUP"]));//PACKINGGROUP
|
|
|
data.ISPOLLUTEOCEAN = (reader["ISPOLLUTEOCEAN"] == null ? false : Convert.ToBoolean(reader["ISPOLLUTEOCEAN"]));//ISPOLLUTEOCEAN
|
|
|
data.MELTINGPOINTB = (reader["MELTINGPOINTB"] == null ? "" : Convert.ToString(reader["MELTINGPOINTB"]));//MELTINGPOINTB
|
|
|
data.BOILINGPOINTB = (reader["BOILINGPOINTB"] == null ? "" : Convert.ToString(reader["BOILINGPOINTB"]));//BOILINGPOINTB
|
|
|
data.FLASHPOINTB = (reader["FLASHPOINTB"] == null ? "" : Convert.ToString(reader["FLASHPOINTB"]));//FLASHPOINTB
|
|
|
data.MELTINGPOINTE = (reader["MELTINGPOINTE"] == null ? "" : Convert.ToString(reader["MELTINGPOINTE"]));//MELTINGPOINTE
|
|
|
data.BOILINGPOINTE = (reader["BOILINGPOINTE"] == null ? "" : Convert.ToString(reader["BOILINGPOINTE"]));//BOILINGPOINTE
|
|
|
data.FLASHPOINTE = (reader["FLASHPOINTE"] == null ? "" : Convert.ToString(reader["FLASHPOINTE"]));//FLASHPOINTE
|
|
|
data.DENSITY = (reader["DENSITY"] == null ? "" : Convert.ToString(reader["DENSITY"]));//DENSITY
|
|
|
data.PH = (reader["PH"] == null ? "" : Convert.ToString(reader["PH"]));//PH
|
|
|
data.STABILITY = (reader["STABILITY"] == null ? "" : Convert.ToString(reader["STABILITY"]));//STABILITY
|
|
|
data.REACTIVE = (reader["REACTIVE"] == null ? "" : Convert.ToString(reader["REACTIVE"]));//REACTIVE
|
|
|
data.IMDG = (reader["IMDG"] == null ? "" : Convert.ToString(reader["IMDG"]));//IMDG
|
|
|
data.REMARKS = (reader["REMARKS"] == null ? "" : Convert.ToString(reader["REMARKS"]));//REMARKS
|
|
|
data.INPUTBY = (reader["INPUTBY"] == null ? "" : Convert.ToString(reader["INPUTBY"]));//INPUTBY
|
|
|
if (reader["INPUTTIME"] != null && reader["INPUTTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["INPUTTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["INPUTTIME"].ToString().Trim() != "")
|
|
|
{
|
|
|
data.INPUTTIME = Convert.ToDateTime(reader["INPUTTIME"]);//INPUTTIME
|
|
|
}
|
|
|
data.COMPANYID = (reader["COMPANYID"] == null ? "" : Convert.ToString(reader["COMPANYID"]));//COMPANYID
|
|
|
//data.ISDANGEROUS = (reader["ISDANGEROUS"] == null ? false : Convert.ToBoolean(reader["ISDANGEROUS"]));//ISDANGEROUS
|
|
|
data.CodeAndName = (reader["CodeAndName"] == null ? "" : Convert.ToString(reader["CodeAndName"]));//CodeAndName
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
if (isNull)
|
|
|
{
|
|
|
CodeMsdsEntity data2 = new CodeMsdsEntity();
|
|
|
data2.GID = "";//GID
|
|
|
data2.GOODNAME = "";//GOODNAME
|
|
|
data2.TRADEGOODSNAME = "";//TRADEGOODSNAME
|
|
|
data2.CHEMICALGOODSNAME = "";//CHEMICALGOODSNAME
|
|
|
data2.CHEMICALCGOODSNAME = "";//CHEMICALCGOODSNAME
|
|
|
data2.CASNO = "";//CASNO
|
|
|
data2.UNNO = "";//UNNO
|
|
|
data2.DCLASS = "";//DCLASS
|
|
|
data2.SDCLASS = "";//SDCLASS
|
|
|
data2.PACKINGGROUP = "";//PACKINGGROUP
|
|
|
data2.ISPOLLUTEOCEAN = false;//ISPOLLUTEOCEAN
|
|
|
data2.MELTINGPOINTB = "";//MELTINGPOINTB
|
|
|
data2.BOILINGPOINTB = "";//BOILINGPOINTB
|
|
|
data2.FLASHPOINTB = "";//FLASHPOINTB
|
|
|
data2.MELTINGPOINTE = "";//MELTINGPOINTE
|
|
|
data2.BOILINGPOINTE = "";//BOILINGPOINTE
|
|
|
data2.FLASHPOINTE = "";//FLASHPOINTE
|
|
|
data2.DENSITY = "";//DENSITY
|
|
|
data2.PH = "";//PH
|
|
|
data2.STABILITY = "";//STABILITY
|
|
|
data2.REACTIVE = "";//REACTIVE
|
|
|
data2.IMDG = "";//IMDG
|
|
|
data2.REMARKS = "";//REMARKS
|
|
|
data2.INPUTBY = "";//INPUTBY
|
|
|
data2.INPUTTIME = DateTime.Now;//INPUTTIME
|
|
|
data2.COMPANYID = "";//COMPANYID
|
|
|
//data2.ISDANGEROUS = false;//ISDANGEROUS
|
|
|
data2.CodeAndName = "";//CodeAndName
|
|
|
headList.Add(data2);
|
|
|
}
|
|
|
|
|
|
return headList;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 权限范围
|
|
|
public static string GetRangStr(string tb, string userid, string username, string companyid)
|
|
|
{
|
|
|
string str = "";
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
|
|
|
strSql.Append(" from VW_User_Authority ");
|
|
|
strSql.Append(" where [NAME]='MsCrmQuotation' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
|
|
string visiblerange = "4";//可视
|
|
|
string operaterange = "4";//可操作
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);//可视
|
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);//可操作
|
|
|
break;
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
if (visiblerange == "4")//无
|
|
|
{
|
|
|
str = "1=2";
|
|
|
}
|
|
|
else if (visiblerange == "3")//个人
|
|
|
{
|
|
|
str = " CREATEUSER='" + username + "'";
|
|
|
}
|
|
|
else if (visiblerange == "2")//部门
|
|
|
{
|
|
|
if (tb == "index")
|
|
|
{
|
|
|
var rangeDa = new RangeDA();
|
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
|
var userstr = new StringBuilder();
|
|
|
userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')");
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
{
|
|
|
str = "";
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (str == "")
|
|
|
{
|
|
|
str = " (CREATEUSER='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or CREATEUSER='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
};
|
|
|
}
|
|
|
str = str + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " CORPID='" + companyid + "'";
|
|
|
}
|
|
|
}
|
|
|
else if (visiblerange == "1")//分公司
|
|
|
{
|
|
|
str = " CORPID='" + companyid + "'";
|
|
|
}
|
|
|
return str;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|