You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1188 lines
70 KiB
C#

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsCrmPriceCarrier;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
using System.Data.SqlClient;
using DSWeb.DataAccess;
using HcUtility.Core;
using DSWeb.Areas.CommMng.DAL;
//需求编号SR2017091200003
namespace DSWeb.MvcShipping.DAL.MsCrmPriceCarrierDAL
{
public class MsCrmPriceCarrierDAL
{
#region 查询
static public List<MsCrmPriceCarrier> GetDataList(string strCondition, int start, int limit, string userid, string usercode, string companyid, string sort = null)
{
var strSql = new StringBuilder();
string sSql = GetDataListSQL(strCondition,start,limit,userid, usercode, companyid,sort);
strSql.Append(sSql);
//
//var sortstring = DatasetSort.Getsortstring(sort);
//if (!string.IsNullOrEmpty(sortstring))
//{
// strSql.Append(" order by " + sortstring);
//}
//else
//{
// strSql.Append(" order by [EFFECTIVEDATE],[VALIDDATE],PORTDISCHARGEID,CARRIER,ETD,TT");
//}
return SetData(strSql);
}
public static int getTotalCount(string strCondition, string userid, string usercode, string companyid)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(*) ");
strSql.Append(" from [crm_price_carrier_2] where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
int cnt = 0;
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
cnt = Convert.ToInt32(reader[0]);
}
}
return cnt;
}
static public string GetDataListStr(string strCondition, string userid, string usercode, string companyid, string sort = null)
{
var strSql = new StringBuilder();
// string sSql = GetDataListSQL(strCondition, userid, usercode, companyid);
strSql.Append("select *");
strSql.Append(",(select ShowName from [user] where GID=INPUTBY) as INPUTBYREF");
strSql.Append(" from [crm_price_carrier_2] where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(" order by [EFFECTIVEDATE],[VALIDDATE],PORTDISCHARGEID,CARRIER,ETD,TT");
return strSql.ToString();
}
static public string GetDataListSQL(string strCondition, int start, int limit, string userid, string usercode, string companyid, string sort = null)
{
var strSql = new StringBuilder();
#region 获取动态列名
/*
strSql.Append("select [GID],[LOCKFLAG],[ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[ETD],[TT],[EFFECTIVEDATE],[VALIDDATE],[COMMODITY],[REMARK],[INPUTBY],[INPUTTIME],[MODIFIEDUSER],[MODIFYTIME]");
#region 获取动态 费用列名
List<XiaLaKuangModel> feeList = GetFeeName();
foreach (var enumValue in feeList)
{
if (enumValue.NAME.ToString().Trim() != "")
{
strSql.Append("," + enumValue.VALUE.ToString().Trim());
}
}
#endregion
#region 获取动态 集装箱列名
List<XiaLaKuangModel> ctnList = MsCrmPriceCarrierDAL.GetCtn();
List<XiaLaKuangModel> BaoJiaList = MsCrmPriceCarrierDAL.GetBaoJia();
foreach (var enumValue in ctnList)
{
foreach (var enumValue2 in BaoJiaList)
{
if (enumValue.NAME.ToString().Trim() != "" && enumValue2.NAME.ToString().Trim() != "")
{
strSql.Append("," + enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim());
}
}
}
#endregion
*/
#endregion
strSql.Append(@"SELECT * from (SELECT row_number() over (");
//var sortstring = DatasetSort.Getsortstring(sort);
//if (!string.IsNullOrEmpty(sortstring))
//{
// strSql.Append(" order by " + sortstring);
//}
//
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by [EFFECTIVEDATE],[VALIDDATE],PORTDISCHARGEID,CARRIER,ETD,TT");
}
strSql.Append(@") as num , ");
strSql.Append("*");
strSql.Append(",(select ShowName from [user] where GID=INPUTBY) as INPUTBYREF");
strSql.Append(" from [crm_price_carrier_2] where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(@")as t ");
strSql.Append(string.Format("where t.num>{0} and t.num<={1} order by t.num ", start, start + limit));
return strSql.ToString();
}
private static List<MsCrmPriceCarrier> SetData(StringBuilder strSql)
{
var headList = new List<MsCrmPriceCarrier>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsCrmPriceCarrier data = new MsCrmPriceCarrier();
#region Set DB data to Object
#region 获取固定列名
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//惟一编号
data.LOCKFLAG = (reader["LOCKFLAG"] == null ? false : Convert.ToBoolean(reader["LOCKFLAG"]));//是否锁定
data.ISISSUE = (reader["ISISSUE"] == null ? false : Convert.ToBoolean(reader["ISISSUE"]));//是否发布
data.LANE = (reader["LANE"] == null ? "" : Convert.ToString(reader["LANE"]));//航线
data.PODLOAD = (reader["PODLOAD"] == null ? "" : Convert.ToString(reader["PODLOAD"]));//起运港
data.PORTDISCHARGEID = (reader["PORTDISCHARGEID"] == null ? "" : Convert.ToString(reader["PORTDISCHARGEID"]));//卸货港ID
data.PORTDISCHARGE = (reader["PORTDISCHARGE"] == null ? "" : Convert.ToString(reader["PORTDISCHARGE"]));//卸货港
data.CARRIER = (reader["CARRIER"] == null ? "" : Convert.ToString(reader["CARRIER"]));//船公司
data.VIA = (reader["VIA"] == null ? "" : Convert.ToString(reader["VIA"]));//中转港
data.ETD = (reader["ETD"] == null ? "" : Convert.ToString(reader["ETD"]));//开航日/船期
data.TT = (reader["TT"] == null ? "" : Convert.ToString(reader["TT"]));//航程
if (reader["EFFECTIVEDATE"] != null && reader["EFFECTIVEDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["EFFECTIVEDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["EFFECTIVEDATE"].ToString().Trim() != "")
{
data.EFFECTIVEDATE = Convert.ToDateTime(reader["EFFECTIVEDATE"]);//生效期/开始日期
}
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.COMMODITY = (reader["COMMODITY"] == null ? "" : Convert.ToString(reader["COMMODITY"]));//品名/特殊商品
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//备注
data.INPUTBY = (reader["INPUTBY"] == null ? "" : Convert.ToString(reader["INPUTBY"]));//录入人
data.INPUTBYREF = (reader["INPUTBYREF"] == null ? "" : Convert.ToString(reader["INPUTBYREF"]));//录入人
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"]);//录入日期
}
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//最后一次操作人GID
if (reader["MODIFYTIME"] != null && reader["MODIFYTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["MODIFYTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["MODIFYTIME"].ToString().Trim() != "")
{
data.MODIFYTIME = Convert.ToDateTime(reader["MODIFYTIME"]);//录入日期
}
#endregion
#region 获取动态 费用列名
data.FEE0 = (reader["FEE0"] == null ? "" : Convert.ToString(reader["FEE0"]));//FEE0
data.FEE1 = (reader["FEE1"] == null ? "" : Convert.ToString(reader["FEE1"]));//FEE1
data.FEE2 = (reader["FEE2"] == null ? "" : Convert.ToString(reader["FEE2"]));//FEE2
data.FEE3 = (reader["FEE3"] == null ? "" : Convert.ToString(reader["FEE3"]));//FEE3
data.FEE4 = (reader["FEE4"] == null ? "" : Convert.ToString(reader["FEE4"]));//FEE4
//List<XiaLaKuangModel> feeList = GetFeeName();
//foreach (var enumValue in feeList)
//{
// if (enumValue.NAME.ToString().Trim() != "")
// {
// if (enumValue.VALUE.ToString().Trim() == "FEE0")
// {
// data.FEE0 = (reader["FEE0"] == null ? "" : Convert.ToString(reader["FEE0"]));//FEE0
// }
// else if (enumValue.VALUE.ToString().Trim() == "FEE1")
// {
// data.FEE1 = (reader["FEE1"] == null ? "" : Convert.ToString(reader["FEE1"]));//FEE1
// }
// else if (enumValue.VALUE.ToString().Trim() == "FEE2")
// {
// data.FEE2 = (reader["FEE2"] == null ? "" : Convert.ToString(reader["FEE2"]));//FEE2
// }
// else if (enumValue.VALUE.ToString().Trim() == "FEE3")
// {
// data.FEE3 = (reader["FEE3"] == null ? "" : Convert.ToString(reader["FEE3"]));//FEE3
// }
// else if (enumValue.VALUE.ToString().Trim() == "FEE4")
// {
// data.FEE4 = (reader["FEE4"] == null ? "" : Convert.ToString(reader["FEE4"]));//FEE4
// }
// }
//}
#endregion
#region 获取动态 集装箱列名
//List<XiaLaKuangModel> ctnList = MsCrmPriceCarrierDAL.GetCtn();
//List<XiaLaKuangModel> BaoJiaList = MsCrmPriceCarrierDAL.GetBaoJia();
//foreach (var enumValue in ctnList)
//{
// foreach (var enumValue2 in BaoJiaList)
// {
// if (enumValue.NAME.ToString().Trim() != "" && enumValue2.NAME.ToString().Trim() != "")
// {
// if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN00")
// {
// data.CTN00 = (reader["CTN00"] == null ? 0 : Convert.ToDecimal(reader["CTN00"]));//CTN00
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN10")
// {
// data.CTN10 = (reader["CTN10"] == null ? 0 : Convert.ToDecimal(reader["CTN10"]));//CTN10
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN20")
// {
// data.CTN20 = (reader["CTN20"] == null ? 0 : Convert.ToDecimal(reader["CTN20"]));//CTN20
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN30")
// {
// data.CTN30 = (reader["CTN30"] == null ? 0 : Convert.ToDecimal(reader["CTN30"]));//CTN30
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN40")
// {
// data.CTN40 = (reader["CTN40"] == null ? 0 : Convert.ToDecimal(reader["CTN40"]));//CTN40
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN50")
// {
// data.CTN50 = (reader["CTN50"] == null ? 0 : Convert.ToDecimal(reader["CTN50"]));//CTN50
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN60")
// {
// data.CTN60 = (reader["CTN60"] == null ? 0 : Convert.ToDecimal(reader["CTN60"]));//CTN60
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN70")
// {
// data.CTN70 = (reader["CTN70"] == null ? 0 : Convert.ToDecimal(reader["CTN70"]));//CTN70
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN80")
// {
// data.CTN80 = (reader["CTN80"] == null ? 0 : Convert.ToDecimal(reader["CTN80"]));//CTN80
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN90")
// {
// data.CTN90 = (reader["CTN90"] == null ? 0 : Convert.ToDecimal(reader["CTN90"]));//CTN90
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN01")
// {
// data.CTN01 = (reader["CTN01"] == null ? 0 : Convert.ToDecimal(reader["CTN01"]));//CTN01
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN11")
// {
// data.CTN11 = (reader["CTN11"] == null ? 0 : Convert.ToDecimal(reader["CTN11"]));//CTN11
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN21")
// {
// data.CTN21 = (reader["CTN21"] == null ? 0 : Convert.ToDecimal(reader["CTN21"]));//CTN21
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN31")
// {
// data.CTN31 = (reader["CTN31"] == null ? 0 : Convert.ToDecimal(reader["CTN31"]));//CTN31
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN41")
// {
// data.CTN41 = (reader["CTN41"] == null ? 0 : Convert.ToDecimal(reader["CTN41"]));//CTN41
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN51")
// {
// data.CTN51 = (reader["CTN51"] == null ? 0 : Convert.ToDecimal(reader["CTN51"]));//CTN51
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN61")
// {
// data.CTN61 = (reader["CTN61"] == null ? 0 : Convert.ToDecimal(reader["CTN61"]));//CTN61
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN71")
// {
// data.CTN71 = (reader["CTN71"] == null ? 0 : Convert.ToDecimal(reader["CTN71"]));//CTN71
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN81")
// {
// data.CTN81 = (reader["CTN81"] == null ? 0 : Convert.ToDecimal(reader["CTN81"]));//CTN81
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN91")
// {
// data.CTN91 = (reader["CTN91"] == null ? 0 : Convert.ToDecimal(reader["CTN91"]));//CTN91
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN02")
// {
// data.CTN02 = (reader["CTN02"] == null ? 0 : Convert.ToDecimal(reader["CTN02"]));//CTN02
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN12")
// {
// data.CTN12 = (reader["CTN12"] == null ? 0 : Convert.ToDecimal(reader["CTN12"]));//CTN12
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN22")
// {
// data.CTN22 = (reader["CTN22"] == null ? 0 : Convert.ToDecimal(reader["CTN22"]));//CTN22
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN32")
// {
// data.CTN32 = (reader["CTN32"] == null ? 0 : Convert.ToDecimal(reader["CTN32"]));//CTN32
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN42")
// {
// data.CTN42 = (reader["CTN42"] == null ? 0 : Convert.ToDecimal(reader["CTN42"]));//CTN42
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN52")
// {
// data.CTN52 = (reader["CTN52"] == null ? 0 : Convert.ToDecimal(reader["CTN52"]));//CTN52
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN62")
// {
// data.CTN62 = (reader["CTN62"] == null ? 0 : Convert.ToDecimal(reader["CTN62"]));//CTN62
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN72")
// {
// data.CTN72 = (reader["CTN72"] == null ? 0 : Convert.ToDecimal(reader["CTN72"]));//CTN72
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN82")
// {
// data.CTN82 = (reader["CTN82"] == null ? 0 : Convert.ToDecimal(reader["CTN82"]));//CTN82
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN92")
// {
// data.CTN92 = (reader["CTN92"] == null ? 0 : Convert.ToDecimal(reader["CTN92"]));//CTN92
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN03")
// {
// data.CTN03 = (reader["CTN03"] == null ? 0 : Convert.ToDecimal(reader["CTN03"]));//CTN03
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN13")
// {
// data.CTN13 = (reader["CTN13"] == null ? 0 : Convert.ToDecimal(reader["CTN13"]));//CTN13
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN23")
// {
// data.CTN23 = (reader["CTN23"] == null ? 0 : Convert.ToDecimal(reader["CTN23"]));//CTN23
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN33")
// {
// data.CTN33 = (reader["CTN33"] == null ? 0 : Convert.ToDecimal(reader["CTN33"]));//CTN33
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN43")
// {
// data.CTN43 = (reader["CTN43"] == null ? 0 : Convert.ToDecimal(reader["CTN43"]));//CTN43
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN53")
// {
// data.CTN53 = (reader["CTN53"] == null ? 0 : Convert.ToDecimal(reader["CTN53"]));//CTN53
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN63")
// {
// data.CTN63 = (reader["CTN63"] == null ? 0 : Convert.ToDecimal(reader["CTN63"]));//CTN63
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN73")
// {
// data.CTN73 = (reader["CTN73"] == null ? 0 : Convert.ToDecimal(reader["CTN73"]));//CTN73
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN83")
// {
// data.CTN83 = (reader["CTN83"] == null ? 0 : Convert.ToDecimal(reader["CTN83"]));//CTN83
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN93")
// {
// data.CTN93 = (reader["CTN93"] == null ? 0 : Convert.ToDecimal(reader["CTN93"]));//CTN93
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN04")
// {
// data.CTN04 = (reader["CTN04"] == null ? 0 : Convert.ToDecimal(reader["CTN04"]));//CTN04
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN14")
// {
// data.CTN14 = (reader["CTN14"] == null ? 0 : Convert.ToDecimal(reader["CTN14"]));//CTN14
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN24")
// {
// data.CTN24 = (reader["CTN24"] == null ? 0 : Convert.ToDecimal(reader["CTN24"]));//CTN24
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN34")
// {
// data.CTN34 = (reader["CTN34"] == null ? 0 : Convert.ToDecimal(reader["CTN34"]));//CTN34
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN44")
// {
// data.CTN44 = (reader["CTN44"] == null ? 0 : Convert.ToDecimal(reader["CTN44"]));//CTN44
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN54")
// {
// data.CTN54 = (reader["CTN54"] == null ? 0 : Convert.ToDecimal(reader["CTN54"]));//CTN54
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN64")
// {
// data.CTN64 = (reader["CTN64"] == null ? 0 : Convert.ToDecimal(reader["CTN64"]));//CTN64
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN74")
// {
// data.CTN74 = (reader["CTN74"] == null ? 0 : Convert.ToDecimal(reader["CTN74"]));//CTN74
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN84")
// {
// data.CTN84 = (reader["CTN84"] == null ? 0 : Convert.ToDecimal(reader["CTN84"]));//CTN84
// }
// else if ((enumValue.VALUE.ToString().Trim() + enumValue2.VALUE.ToString().Trim()) == "CTN94")
// {
// data.CTN94 = (reader["CTN94"] == null ? 0 : Convert.ToDecimal(reader["CTN94"]));//CTN94
// }
// }
// }
//}
data.CTN00 = (reader["CTN00"] == null ? 0 : Convert.ToDecimal(reader["CTN00"]));//CTN00
data.CTN10 = (reader["CTN10"] == null ? 0 : Convert.ToDecimal(reader["CTN10"]));//CTN10
data.CTN20 = (reader["CTN20"] == null ? 0 : Convert.ToDecimal(reader["CTN20"]));//CTN20
data.CTN30 = (reader["CTN30"] == null ? 0 : Convert.ToDecimal(reader["CTN30"]));//CTN30
data.CTN40 = (reader["CTN40"] == null ? 0 : Convert.ToDecimal(reader["CTN40"]));//CTN40
data.CTN50 = (reader["CTN50"] == null ? 0 : Convert.ToDecimal(reader["CTN50"]));//CTN50
data.CTN60 = (reader["CTN60"] == null ? 0 : Convert.ToDecimal(reader["CTN60"]));//CTN60
data.CTN70 = (reader["CTN70"] == null ? 0 : Convert.ToDecimal(reader["CTN70"]));//CTN70
data.CTN80 = (reader["CTN80"] == null ? 0 : Convert.ToDecimal(reader["CTN80"]));//CTN80
data.CTN90 = (reader["CTN90"] == null ? 0 : Convert.ToDecimal(reader["CTN90"]));//CTN90
data.CTN01 = (reader["CTN01"] == null ? 0 : Convert.ToDecimal(reader["CTN01"]));//CTN01
data.CTN11 = (reader["CTN11"] == null ? 0 : Convert.ToDecimal(reader["CTN11"]));//CTN11
data.CTN21 = (reader["CTN21"] == null ? 0 : Convert.ToDecimal(reader["CTN21"]));//CTN21
data.CTN31 = (reader["CTN31"] == null ? 0 : Convert.ToDecimal(reader["CTN31"]));//CTN31
data.CTN41 = (reader["CTN41"] == null ? 0 : Convert.ToDecimal(reader["CTN41"]));//CTN41
data.CTN51 = (reader["CTN51"] == null ? 0 : Convert.ToDecimal(reader["CTN51"]));//CTN51
data.CTN61 = (reader["CTN61"] == null ? 0 : Convert.ToDecimal(reader["CTN61"]));//CTN61
data.CTN71 = (reader["CTN71"] == null ? 0 : Convert.ToDecimal(reader["CTN71"]));//CTN71
data.CTN81 = (reader["CTN81"] == null ? 0 : Convert.ToDecimal(reader["CTN81"]));//CTN81
data.CTN91 = (reader["CTN91"] == null ? 0 : Convert.ToDecimal(reader["CTN91"]));//CTN91
data.CTN02 = (reader["CTN02"] == null ? 0 : Convert.ToDecimal(reader["CTN02"]));//CTN02
data.CTN12 = (reader["CTN12"] == null ? 0 : Convert.ToDecimal(reader["CTN12"]));//CTN12
data.CTN22 = (reader["CTN22"] == null ? 0 : Convert.ToDecimal(reader["CTN22"]));//CTN22
data.CTN32 = (reader["CTN32"] == null ? 0 : Convert.ToDecimal(reader["CTN32"]));//CTN32
data.CTN42 = (reader["CTN42"] == null ? 0 : Convert.ToDecimal(reader["CTN42"]));//CTN42
data.CTN52 = (reader["CTN52"] == null ? 0 : Convert.ToDecimal(reader["CTN52"]));//CTN52
data.CTN62 = (reader["CTN62"] == null ? 0 : Convert.ToDecimal(reader["CTN62"]));//CTN62
data.CTN72 = (reader["CTN72"] == null ? 0 : Convert.ToDecimal(reader["CTN72"]));//CTN72
data.CTN82 = (reader["CTN82"] == null ? 0 : Convert.ToDecimal(reader["CTN82"]));//CTN82
data.CTN92 = (reader["CTN92"] == null ? 0 : Convert.ToDecimal(reader["CTN92"]));//CTN92
data.CTN03 = (reader["CTN03"] == null ? 0 : Convert.ToDecimal(reader["CTN03"]));//CTN03
data.CTN13 = (reader["CTN13"] == null ? 0 : Convert.ToDecimal(reader["CTN13"]));//CTN13
data.CTN23 = (reader["CTN23"] == null ? 0 : Convert.ToDecimal(reader["CTN23"]));//CTN23
data.CTN33 = (reader["CTN33"] == null ? 0 : Convert.ToDecimal(reader["CTN33"]));//CTN33
data.CTN43 = (reader["CTN43"] == null ? 0 : Convert.ToDecimal(reader["CTN43"]));//CTN43
data.CTN53 = (reader["CTN53"] == null ? 0 : Convert.ToDecimal(reader["CTN53"]));//CTN53
data.CTN63 = (reader["CTN63"] == null ? 0 : Convert.ToDecimal(reader["CTN63"]));//CTN63
data.CTN73 = (reader["CTN73"] == null ? 0 : Convert.ToDecimal(reader["CTN73"]));//CTN73
data.CTN83 = (reader["CTN83"] == null ? 0 : Convert.ToDecimal(reader["CTN83"]));//CTN83
data.CTN93 = (reader["CTN93"] == null ? 0 : Convert.ToDecimal(reader["CTN93"]));//CTN93
data.CTN04 = (reader["CTN04"] == null ? 0 : Convert.ToDecimal(reader["CTN04"]));//CTN04
data.CTN14 = (reader["CTN14"] == null ? 0 : Convert.ToDecimal(reader["CTN14"]));//CTN14
data.CTN24 = (reader["CTN24"] == null ? 0 : Convert.ToDecimal(reader["CTN24"]));//CTN24
data.CTN34 = (reader["CTN34"] == null ? 0 : Convert.ToDecimal(reader["CTN34"]));//CTN34
data.CTN44 = (reader["CTN44"] == null ? 0 : Convert.ToDecimal(reader["CTN44"]));//CTN44
data.CTN54 = (reader["CTN54"] == null ? 0 : Convert.ToDecimal(reader["CTN54"]));//CTN54
data.CTN64 = (reader["CTN64"] == null ? 0 : Convert.ToDecimal(reader["CTN64"]));//CTN64
data.CTN74 = (reader["CTN74"] == null ? 0 : Convert.ToDecimal(reader["CTN74"]));//CTN74
data.CTN84 = (reader["CTN84"] == null ? 0 : Convert.ToDecimal(reader["CTN84"]));//CTN84
data.CTN94 = (reader["CTN94"] == null ? 0 : Convert.ToDecimal(reader["CTN94"]));//CTN94
#endregion
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 删除
public static DBResult Delete(string gids, string companyid, string userid)
{
var sGids = " and GID in ('" + gids.Replace(",", "','") + "')";
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_price_carrier_2 where LOCKFLAG=0 and ISISSUE=0" + sGids);
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 onAlterClick(string sEFFECTIVEDATE, string sVALIDDATE, string sCTN, string sYJJB, string sFee, string gids, string userid)
{
string condition = " and GID in ('" + gids.Replace(",", "','") + "')";
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
string sSQL = "update [crm_price_carrier_2] set [MODIFIEDUSER]='" + userid + "',[MODIFYTIME]=getdate()";
if (sEFFECTIVEDATE != "")
{
sSQL += ",[EFFECTIVEDATE]='" + sEFFECTIVEDATE + "'";
}
if (sVALIDDATE != "")
{
sSQL += ",[VALIDDATE]='" + sVALIDDATE + "'";
}
if (sCTN != "" && sYJJB != "" && sFee != "")
{
sSQL += ",[" + sCTN + sYJJB + "]='" + sFee + "'";
}
sSQL += " where LOCKFLAG=0 and ISISSUE=0" + condition;
var cmdDelete = db.GetSqlStringCommand(sSQL);
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 onCopyClick(string sEFFECTIVEDATE, string sVALIDDATE, string gids,string ISCOPYYJ,string userid)
{
string condition = " and GID in ('" + gids.Replace(",", "','") + "')";
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
if (ISCOPYYJ == "1")
{
if (sEFFECTIVEDATE != "" && sVALIDDATE != "")
{
string sSQL = "INSERT INTO [crm_price_carrier_2]([GID],[LOCKFLAG],[ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[ETD],[TT],[EFFECTIVEDATE],[VALIDDATE],[COMMODITY],[REMARK],[INPUTBY],[INPUTTIME],[MODIFIEDUSER],[MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],[CTN00],[CTN10],[CTN20],[CTN30],[CTN40],[CTN50],[CTN60],[CTN70],[CTN80],[CTN90],[CTN01],[CTN11],[CTN21],[CTN31],[CTN41],[CTN51],[CTN61],[CTN71],[CTN81],[CTN91],[CTN02],[CTN12],[CTN22],[CTN32],[CTN42],[CTN52],[CTN62],[CTN72],[CTN82],[CTN92],[CTN03],[CTN13],[CTN23],[CTN33],[CTN43],[CTN53],[CTN63],[CTN73],[CTN83],[CTN93],[CTN04],[CTN14],[CTN24],[CTN34],[CTN44],[CTN54],[CTN64],[CTN74],[CTN84],[CTN94])"
+ "select newid() as [GID],0 as [LOCKFLAG],0 as [ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[ETD],[TT],'" + sEFFECTIVEDATE + "' as [EFFECTIVEDATE],'" + sVALIDDATE + "' as [VALIDDATE],[COMMODITY],[REMARK],'" + userid + "' as [INPUTBY],getdate() as [INPUTTIME],'" + userid + "' as [MODIFIEDUSER],getdate() as [MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],[CTN00],[CTN10],[CTN20],[CTN30],[CTN40],[CTN50],[CTN60],[CTN70],[CTN80],[CTN90],[CTN01],[CTN11],[CTN21],[CTN31],[CTN41],[CTN51],[CTN61],[CTN71],[CTN81],[CTN91],[CTN02],[CTN12],[CTN22],[CTN32],[CTN42],[CTN52],[CTN62],[CTN72],[CTN82],[CTN92],[CTN03],[CTN13],[CTN23],[CTN33],[CTN43],[CTN53],[CTN63],[CTN73],[CTN83],[CTN93],[CTN04],[CTN14],[CTN24],[CTN34],[CTN44],[CTN54],[CTN64],[CTN74],[CTN84],[CTN94]"
+ " from crm_price_carrier_2 where 1=1" + condition;
var cmdDelete = db.GetSqlStringCommand(sSQL);
db.ExecuteNonQuery(cmdDelete, tran);
}
else
{
string sSQL = "INSERT INTO [crm_price_carrier_2]([GID],[LOCKFLAG],[ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[ETD],[TT],[EFFECTIVEDATE],[VALIDDATE],[COMMODITY],[REMARK],[INPUTBY],[INPUTTIME],[MODIFIEDUSER],[MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],[CTN00],[CTN10],[CTN20],[CTN30],[CTN40],[CTN50],[CTN60],[CTN70],[CTN80],[CTN90],[CTN01],[CTN11],[CTN21],[CTN31],[CTN41],[CTN51],[CTN61],[CTN71],[CTN81],[CTN91],[CTN02],[CTN12],[CTN22],[CTN32],[CTN42],[CTN52],[CTN62],[CTN72],[CTN82],[CTN92],[CTN03],[CTN13],[CTN23],[CTN33],[CTN43],[CTN53],[CTN63],[CTN73],[CTN83],[CTN93],[CTN04],[CTN14],[CTN24],[CTN34],[CTN44],[CTN54],[CTN64],[CTN74],[CTN84],[CTN94])"
+ "select newid() as [GID],0 as [LOCKFLAG],0 as [ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[ETD],[TT],[EFFECTIVEDATE],[VALIDDATE],[COMMODITY],[REMARK],'" + userid + "' as [INPUTBY],getdate() as [INPUTTIME],'" + userid + "' as [MODIFIEDUSER],getdate() as [MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],[CTN00],[CTN10],[CTN20],[CTN30],[CTN40],[CTN50],[CTN60],[CTN70],[CTN80],[CTN90],[CTN01],[CTN11],[CTN21],[CTN31],[CTN41],[CTN51],[CTN61],[CTN71],[CTN81],[CTN91],[CTN02],[CTN12],[CTN22],[CTN32],[CTN42],[CTN52],[CTN62],[CTN72],[CTN82],[CTN92],[CTN03],[CTN13],[CTN23],[CTN33],[CTN43],[CTN53],[CTN63],[CTN73],[CTN83],[CTN93],[CTN04],[CTN14],[CTN24],[CTN34],[CTN44],[CTN54],[CTN64],[CTN74],[CTN84],[CTN94]"
+ " from crm_price_carrier_2 where 1=1" + condition;
var cmdDelete = db.GetSqlStringCommand(sSQL);
db.ExecuteNonQuery(cmdDelete, tran);
}
}
else {
if (sEFFECTIVEDATE != "" && sVALIDDATE != "")
{
string sSQL = "INSERT INTO [crm_price_carrier_2]([GID],[LOCKFLAG],[ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[ETD],[TT],[EFFECTIVEDATE],[VALIDDATE],[COMMODITY],[REMARK],[INPUTBY],[INPUTTIME],[MODIFIEDUSER],[MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],[CTN00],[CTN10],[CTN20],[CTN30],[CTN40],[CTN50],[CTN60],[CTN70],[CTN80],[CTN90],[CTN01],[CTN11],[CTN21],[CTN31],[CTN41],[CTN51],[CTN61],[CTN71],[CTN81],[CTN91],[CTN02],[CTN12],[CTN22],[CTN32],[CTN42],[CTN52],[CTN62],[CTN72],[CTN82],[CTN92],[CTN03],[CTN13],[CTN23],[CTN33],[CTN43],[CTN53],[CTN63],[CTN73],[CTN83],[CTN93],[CTN04],[CTN14],[CTN24],[CTN34],[CTN44],[CTN54],[CTN64],[CTN74],[CTN84],[CTN94])"
+ "select newid() as [GID],0 as [LOCKFLAG],0 as [ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[ETD],[TT],'" + sEFFECTIVEDATE + "' as [EFFECTIVEDATE],'" + sVALIDDATE + "' as [VALIDDATE],[COMMODITY],[REMARK],'" + userid + "' as [INPUTBY],getdate() as [INPUTTIME],'" + userid + "' as [MODIFIEDUSER],getdate() as [MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
+ " from crm_price_carrier_2 where 1=1" + condition;
var cmdDelete = db.GetSqlStringCommand(sSQL);
db.ExecuteNonQuery(cmdDelete, tran);
}
else
{
string sSQL = "INSERT INTO [crm_price_carrier_2]([GID],[LOCKFLAG],[ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[ETD],[TT],[EFFECTIVEDATE],[VALIDDATE],[COMMODITY],[REMARK],[INPUTBY],[INPUTTIME],[MODIFIEDUSER],[MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],[CTN00],[CTN10],[CTN20],[CTN30],[CTN40],[CTN50],[CTN60],[CTN70],[CTN80],[CTN90],[CTN01],[CTN11],[CTN21],[CTN31],[CTN41],[CTN51],[CTN61],[CTN71],[CTN81],[CTN91],[CTN02],[CTN12],[CTN22],[CTN32],[CTN42],[CTN52],[CTN62],[CTN72],[CTN82],[CTN92],[CTN03],[CTN13],[CTN23],[CTN33],[CTN43],[CTN53],[CTN63],[CTN73],[CTN83],[CTN93],[CTN04],[CTN14],[CTN24],[CTN34],[CTN44],[CTN54],[CTN64],[CTN74],[CTN84],[CTN94])"
+ "select newid() as [GID],0 as [LOCKFLAG],0 as [ISISSUE],[LANE],[PODLOAD],[PORTDISCHARGEID],[PORTDISCHARGE],[CARRIER],[VIA],[ETD],[TT],[EFFECTIVEDATE],[VALIDDATE],[COMMODITY],[REMARK],'" + userid + "' as [INPUTBY],getdate() as [INPUTTIME],'" + userid + "' as [MODIFIEDUSER],getdate() as [MODIFYTIME],[FEE0],[FEE1],[FEE2],[FEE3],[FEE4],0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
+ " from crm_price_carrier_2 where 1=1" + condition;
var cmdDelete = db.GetSqlStringCommand(sSQL);
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 onLockflagClick(string gids, string companyid, string userid)
{
var sGids = " and GID in ('" + gids.Replace(",", "','") + "')";
var sLINKGID = " and LINKGID in ('" + gids.Replace(",", "','") + "')";
var result = new DBResult();
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
string sSQL = "select name from syscolumns where id=object_id('crm_price_carrier_2') and ([name] like 'CTN%')";//[name] like 'FEE%' or
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
//
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
//插入运价的修改次数
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
var cmdSQL2 = db.GetSqlStringCommand("INSERT INTO [crm_price_carrier_detail]([GID],[LINKGID],[FIELDNAME],[FIELDTYPE],[FIELDCONTENT],[MODIFIEDUSER],[MODIFYTIME]) "
+ " select newid() as GID,LINKGID,FIELDNAME,FIELDTYPE,FIELDCONTENT=(select top 1 [" + ds.Tables[0].Rows[i]["name"].ToString() + "] from crm_price_carrier_2 where gid=crm_price_carrier_detail.LINKGID),'" + userid + "' as [MODIFIEDUSER],getdate() as [MODIFYTIME] from crm_price_carrier_detail "
+ " where FIELDTYPE=2 and FIELDNAME='" + ds.Tables[0].Rows[i]["name"].ToString() + "' and FIELDCONTENT<>isnull((select top 1 [" + ds.Tables[0].Rows[i]["name"].ToString() + "] from crm_price_carrier_2 where gid=crm_price_carrier_detail.LINKGID),0) and gid in (select top 1 gid from crm_price_carrier_detail as a where FIELDNAME='" + ds.Tables[0].Rows[i]["name"].ToString() + "' and FIELDTYPE=2 and a.LINKGID=crm_price_carrier_detail.LINKGID order by MODIFYTIME desc ) " + sLINKGID);
db.ExecuteNonQuery(cmdSQL2, tran);
}
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
var cmdSQL2 = db.GetSqlStringCommand("INSERT INTO [crm_price_carrier_detail]([GID],[LINKGID],[FIELDNAME],[FIELDTYPE],[FIELDCONTENT],[MODIFIEDUSER],[MODIFYTIME])"
+ " select newid() as GID,GID as LINKGID,'" + ds.Tables[0].Rows[i]["name"].ToString() + "' as FIELDNAME,2 as FIELDTYPE,[" + ds.Tables[0].Rows[i]["name"].ToString() + "] as FIELDCONTENT,'" + userid + "' as [MODIFIEDUSER],getdate() as [MODIFYTIME]"
+ " from crm_price_carrier_2"
+ " where LOCKFLAG=0 and ISISSUE=0 and gid not in (select linkgid from crm_price_carrier_detail where FIELDNAME='" + ds.Tables[0].Rows[i]["name"].ToString() + "' and FIELDTYPE=2) " + sGids);
db.ExecuteNonQuery(cmdSQL2, tran);
}
}
}
var cmdSQL = db.GetSqlStringCommand("update crm_price_carrier_2 set LOCKFLAG=1 where LOCKFLAG=0 and ISISSUE=0" + sGids);
db.ExecuteNonQuery(cmdSQL, 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 onNotLockflagClick(string gids, string companyid, string userid)
{
var sGids = " and GID in ('" + gids.Replace(",", "','") + "')";
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdDelete = db.GetSqlStringCommand("update crm_price_carrier_2 set LOCKFLAG=0 where LOCKFLAG=1 and ISISSUE=0" + sGids);
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 onAllLockflagClick(string companyid, string userid)
{
var sLINKGID = " and LINKGID in (select gid from crm_price_carrier_2 where LOCKFLAG=0 and ISISSUE=0)";
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
string sSQL = "select name from syscolumns where id=object_id('crm_price_carrier_2') and ([name] like 'CTN%')";//[name] like 'FEE%' or
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
//
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
//插入运价的修改次数
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
var cmdSQL2 = db.GetSqlStringCommand("INSERT INTO [crm_price_carrier_detail]([GID],[LINKGID],[FIELDNAME],[FIELDTYPE],[FIELDCONTENT],[MODIFIEDUSER],[MODIFYTIME]) "
+ " select newid() as GID,LINKGID,FIELDNAME,FIELDTYPE,FIELDCONTENT=(select top 1 [" + ds.Tables[0].Rows[i]["name"].ToString() + "] from crm_price_carrier_2 where gid=crm_price_carrier_detail.LINKGID),'" + userid + "' as [MODIFIEDUSER],getdate() as [MODIFYTIME]"
+ " from crm_price_carrier_detail "
+ " where FIELDTYPE=2 and FIELDNAME='" + ds.Tables[0].Rows[i]["name"].ToString() + "' and FIELDCONTENT<>isnull((select top 1 [" + ds.Tables[0].Rows[i]["name"].ToString() + "] from crm_price_carrier_2 where gid=crm_price_carrier_detail.LINKGID),0) and gid in (select top 1 gid from crm_price_carrier_detail as a where FIELDNAME='" + ds.Tables[0].Rows[i]["name"].ToString() + "' and FIELDTYPE=2 and a.LINKGID=crm_price_carrier_detail.LINKGID order by MODIFYTIME desc ) " + sLINKGID);
db.ExecuteNonQuery(cmdSQL2, tran);
}
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
var cmdSQL2 = db.GetSqlStringCommand("INSERT INTO [crm_price_carrier_detail]([GID],[LINKGID],[FIELDNAME],[FIELDTYPE],[FIELDCONTENT],[MODIFIEDUSER],[MODIFYTIME])"
+ " select newid() as GID,GID as LINKGID,'" + ds.Tables[0].Rows[i]["name"].ToString() + "' as FIELDNAME,2 as FIELDTYPE,[" + ds.Tables[0].Rows[i]["name"].ToString() + "] as FIELDCONTENT,'" + userid + "' as [MODIFIEDUSER],getdate() as [MODIFYTIME]"
+ " from crm_price_carrier_2"
+ " where LOCKFLAG=0 and ISISSUE=0 and gid not in (select linkgid from crm_price_carrier_detail where FIELDNAME='" + ds.Tables[0].Rows[i]["name"].ToString() + "' and FIELDTYPE=2) ");
db.ExecuteNonQuery(cmdSQL2, tran);
}
}
}
var cmdDelete = db.GetSqlStringCommand("update crm_price_carrier_2 set LOCKFLAG=1 where LOCKFLAG=0 and ISISSUE=0");
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 onNotAllLockflagClick(string companyid, string userid)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdDelete = db.GetSqlStringCommand("update crm_price_carrier_2 set LOCKFLAG=0 where LOCKFLAG=1 and ISISSUE=0");
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 onIsissueClick(string gids, string companyid, string userid)
{
var sGids = " and GID in ('" + gids.Replace(",", "','") + "')";
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdDelete = db.GetSqlStringCommand("update crm_price_carrier_2 set Isissue=1 where Lockflag=1 and ISISSUE=0" + sGids);
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 onNotIsissueClick(string gids, string companyid, string userid)
{
var sGids = " and GID in ('" + gids.Replace(",", "','") + "')";
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdDelete = db.GetSqlStringCommand("update crm_price_carrier_2 set Isissue=0 where Lockflag=1 and ISISSUE=1" + sGids);
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 onAllIsissueClick(string companyid, string userid)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdDelete = db.GetSqlStringCommand("update crm_price_carrier_2 set Isissue=1 where Lockflag=1 and ISISSUE=0");
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 onNotAllIsissueClick(string companyid, string userid)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdDelete = db.GetSqlStringCommand("update crm_price_carrier_2 set Isissue=0 where Lockflag=1 and ISISSUE=1");
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 onYunJiaBiaoShiClick(string gids, string sFIELDNAME, int iFIELDTYPE, string sFIELDCONTENT, string companyid, string userid)
{
var sGids = " and LINKGID in ('" + gids.Replace(",", "','") + "')";
var sGids2 = " and GID in ('" + gids.Replace(",", "','") + "')";
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdSQL = db.GetSqlStringCommand("delete crm_price_carrier_detail where FIELDNAME='" + sFIELDNAME + "' and FIELDTYPE=" + iFIELDTYPE + sGids);//
db.ExecuteNonQuery(cmdSQL, tran);
cmdSQL = db.GetSqlStringCommand("INSERT INTO [crm_price_carrier_detail]([GID],[LINKGID],[FIELDNAME],[FIELDTYPE],[FIELDCONTENT],[MODIFIEDUSER],[MODIFYTIME]) select newid() as GID,GID as LINKGID,'" + sFIELDNAME + "' as FIELDNAME," + iFIELDTYPE + " as FIELDTYPE,(case when " + iFIELDTYPE + "=1 then isnull((select top 1 ENUMVALUEID from tSysEnumValue where ENUMTYPEID=97054 and ENUMVALUENAME='" + sFIELDCONTENT + "'),'" + sFIELDCONTENT + "') else '" + sFIELDCONTENT + "' end) as FIELDCONTENT,'" + userid + "',getdate() as [MODIFYTIME] from crm_price_carrier_2 where 1=1" + sGids2);
db.ExecuteNonQuery(cmdSQL, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "操作失败";
return result;
}
}
result.Success = true;
result.Message = "操作成功";
return result;
}
#endregion
#region 查询运价标识/修改次数
static public List<CrmPriceCarrierDetailModel> GetDataListBiaoShi(string strCondition, string strCondition2, string userid, string usercode, string companyid)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var strSql = new StringBuilder();
strSql.Append("select *,'' as hj from [crm_price_carrier_detail] where LINKGID in (select gid from [crm_price_carrier_2] where 1=1"); //FIELDTYPE=1 and
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(")");
if (!string.IsNullOrEmpty(strCondition2))
{
strSql.Append(" and " + strCondition2);
}
strSql.Append(" order by LINKGID,FIELDTYPE,FIELDNAME,MODIFYTIME");
return SetDataBiaoShi(strSql);
}
static public List<CrmPriceCarrierDetailModel> GetDataListXGCS(string strCondition, string userid, string usercode, string companyid)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var strSql = new StringBuilder();
strSql.Append("select newid() as [GID],[LINKGID],[FIELDNAME],2 as [FIELDTYPE],'' as [FIELDCONTENT],'' as [MODIFIEDUSER],getdate() as [MODIFYTIME],COUNT(*) as hj from [crm_price_carrier_detail] where FIELDTYPE=2 and LINKGID in (select gid from [crm_price_carrier_2] where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(")");
strSql.Append(" group by LINKGID,FIELDNAME order by LINKGID,FIELDNAME");
return SetDataBiaoShi(strSql);
}
private static List<CrmPriceCarrierDetailModel> SetDataBiaoShi(StringBuilder strSql)
{
var headList = new List<CrmPriceCarrierDetailModel>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
CrmPriceCarrierDetailModel data = new CrmPriceCarrierDetailModel();
#region Set DB data to Object
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//惟一编号
data.LINKGID = (reader["LINKGID"] == null ? "" : Convert.ToString(reader["LINKGID"]));//关联 CRM_PRICE_CARRIER_2 的 GID
data.FIELDNAME = (reader["FIELDNAME"] == null ? "" : Convert.ToString(reader["FIELDNAME"]));//字段名称
data.FIELDTYPE = (reader["FIELDTYPE"] == null ? 0 : Convert.ToInt32(reader["FIELDTYPE"]));//字段类型1.颜色2.修改次数3.标识
data.FIELDCONTENT = (reader["FIELDCONTENT"] == null ? "" : Convert.ToString(reader["FIELDCONTENT"]));//字段内容
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//最后一次操作人GID
if (reader["MODIFYTIME"] != null && reader["MODIFYTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["MODIFYTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["MODIFYTIME"].ToString().Trim() != "")
{
data.MODIFYTIME = Convert.ToDateTime(reader["MODIFYTIME"]);//录入日期
}
data.hj = (reader["hj"] == null ? "" : Convert.ToString(reader["hj"]));//合计的修改次数
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 取其他费用权限_循环列
static public List<XiaLaKuangModel> GetFeeName()
{
var strSql = new StringBuilder();
strSql.Append("select [EnumValueID] as [VALUE],[EnumValueName] as [NAME],([EnumValueID] + ' | ' + [EnumValueName]) as CodeAndName from [tSysEnumValue] where [ENUMTYPEID]=97053 and [EnumValueName] is not null and [EnumValueName]<>'' and [EnumValueName]<>' ' order by [DispIndex]");
return SetXiaLaKuang(strSql, false);
}
#endregion
#region 取集装箱权限_循环列
static public List<XiaLaKuangModel> GetCtn()
{
var strSql = new StringBuilder();
strSql.Append("select [EnumValueID] as [VALUE],[EnumValueName] as [NAME],([EnumValueID] + ' | ' + [EnumValueName]) as CodeAndName from [tSysEnumValue] where [ENUMTYPEID]=97051 and [EnumValueName] is not null and [EnumValueName]<>'' and [EnumValueName]<>' ' order by [DispIndex]");
return SetXiaLaKuang(strSql, false);
}
#endregion
#region 取报价权限_循环列
static public List<XiaLaKuangModel> GetBaoJia()
{
var strSql = new StringBuilder();
strSql.Append("select [EnumValueID] as [VALUE],[EnumValueName] as [NAME],([EnumValueID] + ' | ' + [EnumValueName]) as CodeAndName from [tSysEnumValue] where [ENUMTYPEID]=97052 and [EnumValueName] is not null and [EnumValueName]<>'' and [EnumValueName]<>' ' order by [DispIndex]");
return SetXiaLaKuang(strSql, false);
}
static public List<XiaLaKuangModel> GetBaoJiaChaXun()
{
var strSql = new StringBuilder();
strSql.Append("select [EnumValueID] as [VALUE],[EnumValueName] as [NAME],([EnumValueID] + ' | ' + [EnumValueName]) as CodeAndName from [tSysEnumValue] where [ENUMTYPEID]=97052 and EnumValueName_2='true' and [EnumValueName] is not null and [EnumValueName]<>'' and [EnumValueName]<>' ' order by [DispIndex]");
return SetXiaLaKuang(strSql, false);
}
#endregion
#region 启运港国内港口_下拉框
static public List<XiaLaKuangModel> GetPODLOADList()
{
var strSql = new StringBuilder();
strSql.Append("SELECT [PODLOAD] as [VALUE],[PODLOAD] as [NAME],[PODLOAD] as CodeAndName FROM [crm_price_carrier_2] order by [PODLOAD]");
return SetXiaLaKuang(strSql, true);
}
#endregion
#region 目的港国外港口_下拉框
static public List<XiaLaKuangModel> GetPORTDISCHARGEList(string CODENAME)
{
var strSql = new StringBuilder();
strSql.Append("select [PORTDISCHARGEID] as [VALUE],[PORTDISCHARGE] as [NAME],([PORTDISCHARGEID] + ' | ' + [PORTDISCHARGE]) as CodeAndName from [crm_price_carrier_2] ");
if (CODENAME != "") {
strSql.Append(" WHERE PORTDISCHARGEID like '%" + CODENAME + "%' OR PORTDISCHARGE like '%" + CODENAME + "%' ");
}
strSql.Append(" group by [PORTDISCHARGEID],[PORTDISCHARGE] order by [PORTDISCHARGEID],[PORTDISCHARGE]");
return SetXiaLaKuang(strSql, true);
}
#endregion
#region 中转港国外港口_下拉框
static public List<XiaLaKuangModel> GetVIAList()
{
var strSql = new StringBuilder();
strSql.Append("select [VIA] as [VALUE],[VIA] as [NAME],[VIA] as CodeAndName from [crm_price_carrier_2] group by [VIA] order by [VIA]");
return SetXiaLaKuang(strSql, true);
}
#endregion
#region 船公司_下拉框
static public List<XiaLaKuangModel> GetCARRIERList()
{
var strSql = new StringBuilder();
strSql.Append("select distinct [CARRIER] as [VALUE],[CARRIER] as [NAME],[CARRIER] as CodeAndName from [crm_price_carrier_2] group by [CARRIER] order by [CARRIER]");
return SetXiaLaKuang(strSql, true);
}
#endregion
#region 航线_下拉框
static public List<XiaLaKuangModel> GetLANEList(string codename = "")
{
var strSql = new StringBuilder();
strSql.Append("SELECT distinct [LANE] as [VALUE],[LANE] as [NAME],[LANE] as CodeAndName FROM [crm_price_carrier_2] ");
if (!string.IsNullOrEmpty(codename))
{
strSql.Append(" WHERE LANE LIKE '%" + codename + "%'");
}
strSql.Append(" order by [LANE]");
return SetXiaLaKuang(strSql, true);
}
#endregion
#region 下拉框实体类
private static List<XiaLaKuangModel> SetXiaLaKuang(StringBuilder strSql,bool isNull)
{
var headList = new List<XiaLaKuangModel>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
XiaLaKuangModel data = new XiaLaKuangModel();
#region Set DB data to Object
data.VALUE = (reader["VALUE"] == null ? "" : Convert.ToString(reader["VALUE"]).Trim());//列名
data.NAME = (reader["NAME"] == null ? "" : Convert.ToString(reader["NAME"]).Trim());//标题
data.CodeAndName = (reader["CodeAndName"] == null ? "" : Convert.ToString(reader["CodeAndName"]).Trim());//VALUE | NAME
#endregion
headList.Add(data);
}
reader.Close();
}
if (isNull)
{
XiaLaKuangModel data2 = new XiaLaKuangModel();
data2.VALUE = "";//列名
data2.NAME = "";//标题
data2.CodeAndName = "";//VALUE | NAME
headList.Add(data2);
}
return headList;
}
#endregion
}
}