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.
966 lines
38 KiB
C#
966 lines
38 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DSWeb.TruckMng.Models.MsCustTruckFeeTemplate;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
using HcUtility.Comm;
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
using System.Web;
|
|
|
|
namespace DSWeb.TruckMng.DAL.MsCustTruckFeeTemplate
|
|
{
|
|
public class MsCustTruckFeeTempldateDAL
|
|
{
|
|
#region Inquery DataList
|
|
|
|
static public List<CustTruckFeeTemplate> GetDataList(string strCondition, string userid, string usercode, string orgcode, string sort = null)
|
|
{
|
|
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, orgcode);
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strCondition = strCondition + " and " + rangstr ;
|
|
}
|
|
else
|
|
{
|
|
strCondition = rangstr ;
|
|
}
|
|
}
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("[GID],[LINKID],TEMPLATENAME,[CONTRACTNO],[CUSTOMERNAME],[GOODNAME],[TRANTYPE],BSSTATUS,");
|
|
strSql.Append("[REMARK],[CORPID],[CREATEUSER],[CREATETIME],FEEUNIT,PRICEUNIT,DC");
|
|
strSql.Append(",(select ShowName from [user] where GID=Cust_Truck_feetemplate.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(" from Cust_Truck_feetemplate ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else {
|
|
strSql.Append(" order by CREATETIME DESC ");
|
|
|
|
}
|
|
return SetData(strSql);
|
|
}
|
|
|
|
static public List<CustTruckFeeTemplate> GetAuditDataList(string strCondition, string isaudit, string userid, string usercode, string orgcode, string sort = null)
|
|
{
|
|
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, orgcode);
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strCondition = strCondition + " and " + rangstr;
|
|
}
|
|
else
|
|
{
|
|
strCondition = rangstr;
|
|
}
|
|
}
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("Cust_Truck_feetemplate.[GID],Cust_Truck_feetemplate.[LINKID],Cust_Truck_feetemplate.TEMPLATENAME,[CONTRACTNO],[CUSTOMERNAME],[GOODNAME],[TRANTYPE],BSSTATUS,");
|
|
strSql.Append("Cust_Truck_feetemplate.[REMARK],Cust_Truck_feetemplate.[CORPID],Cust_Truck_feetemplate.[CREATEUSER],Cust_Truck_feetemplate.[CREATETIME],Cust_Truck_feetemplate.DC");
|
|
strSql.Append(",(select ShowName from [user] where GID=Cust_Truck_feetemplate.CREATEUSER) as CREATEUSERREF,Cust_Truck_feetemplate.FEEUNIT,Cust_Truck_feetemplate.PRICEUNIT");
|
|
strSql.Append(" from Cust_Truck_feetemplate ");
|
|
strSql.Append(" left join workflow_using wu on wu.bsno=Cust_Truck_feetemplate.GID ");
|
|
if (isaudit == "3")
|
|
strSql.Append(" and dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno)>0 ");
|
|
else if (isaudit == "2")
|
|
{
|
|
strSql.Append(" and Cust_Truck_feetemplate.BSSTATUS='审核通过' ");// AND I.BILLNO IN (select distinct billno from workflow_do where auditor='" + userid + "' ) ");
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
strSql.Append(" and " + rangstr);
|
|
}
|
|
}
|
|
else if (isaudit == "1")
|
|
{
|
|
strSql.Append(" and Cust_Truck_feetemplate.BSSTATUS='提交审核' ");// AND I.BILLNO IN (select distinct billno from workflow_do where auditor='" + userid + "' ) ");
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
strSql.Append(" and " + rangstr);
|
|
}
|
|
}
|
|
else if (isaudit == "")
|
|
{
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
strSql.Append(" and " + rangstr);
|
|
}
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by Cust_Truck_feetemplate.CREATETIME DESC ");
|
|
|
|
}
|
|
return SetData(strSql);
|
|
}
|
|
|
|
static public CustTruckFeeTemplate GetData(string condition)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("[GID],[LINKID],TEMPLATENAME,[CONTRACTNO],[CUSTOMERNAME],[GOODNAME],[TRANTYPE],BSSTATUS,");
|
|
strSql.Append("[REMARK],[CORPID],[CREATEUSER],[CREATETIME],FEEUNIT,PRICEUNIT,DC");
|
|
strSql.Append(",(select ShowName from [user] where GID=Cust_Truck_feetemplate.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(" from Cust_Truck_feetemplate ");
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" where " + condition);
|
|
}
|
|
var list = SetData(strSql);
|
|
if (list.Count > 0)
|
|
{
|
|
return list[0];
|
|
}
|
|
return new CustTruckFeeTemplate();
|
|
}
|
|
|
|
|
|
private static List<CustTruckFeeTemplate> SetData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<CustTruckFeeTemplate>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
CustTruckFeeTemplate data = new CustTruckFeeTemplate();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
|
data.LINKID = Convert.ToString(reader["LINKID"]);
|
|
data.BSSTATUS = Convert.ToString(reader["BSSTATUS"]);
|
|
|
|
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
|
|
data.TEMPLATENAME = Convert.ToString(reader["TEMPLATENAME"]);
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
data.FEEUNIT = Convert.ToString(reader["FEEUNIT"]);
|
|
data.PRICEUNIT = Convert.ToString(reader["PRICEUNIT"]);
|
|
|
|
data.GOODNAME = Convert.ToString(reader["GOODNAME"]);
|
|
data.TRANTYPE = Convert.ToString(reader["TRANTYPE"]);
|
|
data.DC = Convert.ToString(reader["DC"]);
|
|
|
|
data.CORPID = Convert.ToString(reader["CORPID"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]);
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
#region 明细表
|
|
|
|
static public List<CustTruckFeeTemplateDetail> GetBodyList(string strCondition, string sort = null)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("GID,TEMPLATEID,UNITTYPE,UNIT,[LOADPORT],[DISTPORT]");
|
|
strSql.Append(",UNITPRICE,REMARK,CREATEUSER,CREATETIME,STARTWEIGHT,ENDWEIGHT ");
|
|
strSql.Append(" from Cust_Truck_feetemplatedetail ");
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by CREATETIME ");
|
|
}
|
|
|
|
return SetBodyData(strSql);
|
|
}
|
|
|
|
private static List<CustTruckFeeTemplateDetail> SetBodyData(StringBuilder strSql)
|
|
{
|
|
var bodyList = new List<CustTruckFeeTemplateDetail>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
CustTruckFeeTemplateDetail data = new CustTruckFeeTemplateDetail();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.TEMPLATEID = Convert.ToString(reader["TEMPLATEID"]);
|
|
data.UNITTYPE = Convert.ToString(reader["UNITTYPE"]);
|
|
if (reader["UNITPRICE"] != DBNull.Value)
|
|
data.UNITPRICE = Convert.ToDecimal(reader["UNITPRICE"]);
|
|
if (reader["STARTWEIGHT"] != DBNull.Value)
|
|
data.STARTWEIGHT = Convert.ToDecimal(reader["STARTWEIGHT"]);
|
|
if (reader["ENDWEIGHT"] != DBNull.Value)
|
|
data.ENDWEIGHT = Convert.ToDecimal(reader["ENDWEIGHT"]);
|
|
data.UNIT = Convert.ToString(reader["UNIT"]);
|
|
data.LOADPORT = Convert.ToString(reader["LOADPORT"]);
|
|
data.DISTPORT = Convert.ToString(reader["DISTPORT"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
data.CREATETIME = Convert.ToString(reader["CREATETIME"]);
|
|
#endregion
|
|
|
|
bodyList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
return bodyList;
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DBResult SaveDetail(CustTruckFeeTemplate headData, List<CustTruckFeeTemplateDetail> bodyList,string userid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into Cust_Truck_feetemplatedetail (GID,TEMPLATEID,UNITTYPE,UNIT,UNITPRICE,STARTWEIGHT,ENDWEIGHT,REMARK,CREATEUSER,CREATETIME,LOADPORT,DISTPORT)
|
|
values (@GID,@TEMPLATEID,@UNITTYPE,@UNIT,@UNITPRICE,@STARTWEIGHT,@ENDWEIGHT,@REMARK,@CREATEUSER,@CREATETIME,@LOADPORT,@DISTPORT) ");
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update Cust_Truck_feetemplatedetail set UNITTYPE=@UNITTYPE,UNIT=@UNIT,UNITPRICE=@UNITPRICE,STARTWEIGHT=@STARTWEIGHT,ENDWEIGHT=@ENDWEIGHT,REMARK=@REMARK,LOADPORT=@LOADPORT,DISTPORT=@DISTPORT where GID=@GID ");
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
if (enumValue.TEMPLATEID == "*" || enumValue.TEMPLATEID == "")
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@TEMPLATEID", DbType.String,headData.GID);
|
|
db.AddInParameter(cmdInsert, "@UNITTYPE", DbType.String, enumValue.UNITTYPE);
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, enumValue.UNIT);
|
|
db.AddInParameter(cmdInsert, "@UNITPRICE", DbType.Decimal, enumValue.UNITPRICE);
|
|
db.AddInParameter(cmdInsert, "@STARTWEIGHT", DbType.Decimal, enumValue.STARTWEIGHT);
|
|
db.AddInParameter(cmdInsert, "@ENDWEIGHT", DbType.Decimal, enumValue.ENDWEIGHT);
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdInsert, "@LOADPORT", DbType.String, enumValue.LOADPORT);
|
|
db.AddInParameter(cmdInsert, "@DISTPORT", DbType.String, enumValue.DISTPORT);
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString());
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
db.AddInParameter(cmdUpdate, "@UNITTYPE", DbType.String, enumValue.UNITTYPE);
|
|
db.AddInParameter(cmdUpdate, "@UNIT", DbType.String, enumValue.UNIT);
|
|
db.AddInParameter(cmdUpdate, "@UNITPRICE", DbType.Decimal, enumValue.UNITPRICE);
|
|
db.AddInParameter(cmdUpdate, "@STARTWEIGHT", DbType.Decimal, enumValue.STARTWEIGHT);
|
|
db.AddInParameter(cmdUpdate, "@ENDWEIGHT", DbType.Decimal, enumValue.ENDWEIGHT);
|
|
db.AddInParameter(cmdUpdate, "@LOADPORT", DbType.String, enumValue.LOADPORT);
|
|
db.AddInParameter(cmdUpdate, "@DISTPORT", DbType.String, enumValue.DISTPORT);
|
|
db.AddInParameter(cmdUpdate, "@REMARK", DbType.String, enumValue.REMARK);
|
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
}
|
|
}
|
|
}
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
public static DBResult DeleteDetail(CustTruckFeeTemplate headData)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmd = db.GetSqlStringCommand("delete from Cust_Truck_feetemplate where GID='" + headData.GID + "'");
|
|
db.ExecuteNonQuery(cmd, tran);
|
|
var cmdDelete = db.GetSqlStringCommand("delete from Cust_Truck_feetemplatedetail where TEMPLATEID='" + headData.GID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
public static DBResult DeleteTemplateDetail(CustTruckFeeTemplateDetail bodyList)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
//if (bodyList != null)
|
|
//{
|
|
// foreach (var enumValue in bodyList)
|
|
// {
|
|
var cmdDelete = db.GetSqlStringCommand("delete from Cust_Truck_feetemplatedetail where GID='" + bodyList.GID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
// }
|
|
//}
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "删除出现错误,请重试或联系系统管理员"+e.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "删除成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 审核和撤销审核
|
|
public static DBResult SubmitAudit(String USERID, List<CustTruckFeeTemplate> bodyList)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart("CustTruckFeeTemplateAudit", enumValue.GID, USERID,enumValue.CONTRACTNO,enumValue.GID,"");
|
|
|
|
if (WorkResult.Success == true)
|
|
{
|
|
var cmdupdate = db.GetSqlStringCommand("GID=@GID");
|
|
if (WorkResult.islast == true)
|
|
{
|
|
cmdupdate = db.GetSqlStringCommand("update Cust_Truck_feetemplate set BSSTATUS='审核通过',AUDITUSER='" + USERID + "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where GID=@GID");
|
|
}
|
|
else
|
|
{
|
|
cmdupdate = db.GetSqlStringCommand("update Cust_Truck_feetemplate set BSSTATUS='提交审核' where GID=@GID");
|
|
}
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, enumValue.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
result = new DBResult();
|
|
|
|
result.Success = true;
|
|
result.Message = "提交审核成功";
|
|
|
|
}
|
|
else
|
|
{
|
|
result = new DBResult();
|
|
|
|
result.Success = false;
|
|
result.Message = "提交审核错误,请检查工作流!";
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
//if (result.Success != false)
|
|
//{
|
|
// result = new DBResult();
|
|
// result.Success = true;
|
|
// result.Message = "提交审核成功";
|
|
//}
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "提交审核错误,请重试或联系系统管理员 " + e.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult SubmitAuditBack(String USERID, List<CustTruckFeeTemplate> bodyList)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowReset("CustTruckFeeTemplateAudit", enumValue.GID, USERID);
|
|
if (WorkResult.Success == true)
|
|
{
|
|
var cmdupdate = db.GetSqlStringCommand("update Cust_Truck_feetemplate set BSSTATUS='新增' where GID=@GID");
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, enumValue.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "撤销提交成功";
|
|
}
|
|
else
|
|
{
|
|
|
|
result = new DBResult();
|
|
result.Success = false;
|
|
result.Message = "不允许撤回提交!";
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "撤销提交错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
public static DBResult AuditList(List<CustTruckFeeTemplate> boday, String USERID)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
var errmsg = "";
|
|
|
|
if (boday != null)
|
|
{
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update Cust_Truck_feetemplate set BSSTATUS='审核通过',AUDITUSER='" + USERID + "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where GID=@GID");
|
|
var cmdupdate2 = db.GetSqlStringCommand("update Cust_Truck_feetemplate set AUDITUSER='" + USERID + "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where GID=@GID");
|
|
|
|
foreach (var enumValue in boday)
|
|
{
|
|
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo("CustTruckFeeTemplateAudit", enumValue.GID, USERID, tran,enumValue.GID);
|
|
if (WorkResult.Success == true)
|
|
{
|
|
if (WorkResult.islast == true)
|
|
{
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, enumValue.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
}
|
|
else
|
|
{
|
|
cmdupdate2.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate2, "@GID", DbType.String, enumValue.GID);
|
|
db.ExecuteNonQuery(cmdupdate2, tran);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "审核通过";
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "审核出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
public static DBResult AuditBackList(List<CustTruckFeeTemplate> boday, String USERID, string reason)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
|
|
if (boday != null)
|
|
{
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update Cust_Truck_feetemplate set BSSTATUS='驳回提交',AUDITUSER='',AUDITTIME=null,REASON='" + reason + "' where GID=@GID");
|
|
|
|
foreach (var enumValue in boday)
|
|
{
|
|
if (enumValue.BSSTATUS == "提交审核" || enumValue.BSSTATUS == "审核通过")
|
|
{
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.DeleteWorkFlowDo("CustTruckFeeTemplateAudit", enumValue.GID, USERID, reason, enumValue.GID, enumValue.GID, "驳回提交URL");
|
|
if (WorkResult.Success == true)
|
|
{
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, enumValue.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "完成驳回";
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "驳回出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "完成驳回";
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
public static List<FeeUnit> GetFeeUnit(string strCondition)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT CTN from code_ctn");
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
var evList = new List<FeeUnit>();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
FeeUnit Data = new FeeUnit();
|
|
Data.UNIT = Convert.ToString(reader["CTN"]);
|
|
evList.Add(Data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
var data = new FeeUnit();
|
|
data.UNIT = "单票";
|
|
evList.Add(data);
|
|
var data1 = new FeeUnit();
|
|
data1.UNIT = "重量";
|
|
evList.Add(data1);
|
|
var data2 = new FeeUnit();
|
|
data2.UNIT = "尺码";
|
|
evList.Add(data2);
|
|
var data3 = new FeeUnit();
|
|
data3.UNIT = "TEU";
|
|
evList.Add(data3);
|
|
var data4 = new FeeUnit();
|
|
data4.UNIT = "箱型";
|
|
evList.Add(data4);
|
|
var data5 = new FeeUnit();
|
|
data5.UNIT = "CBM";
|
|
evList.Add(data5);
|
|
var data6 = new FeeUnit();
|
|
data6.UNIT = "BILL";
|
|
evList.Add(data6);
|
|
var data7 = new FeeUnit();
|
|
data7.UNIT = "件数";
|
|
evList.Add(data7);
|
|
var data8 = new FeeUnit();
|
|
data8.UNIT = "车";
|
|
evList.Add(data8);
|
|
var data9 = new FeeUnit();
|
|
data9.UNIT = "自然箱";
|
|
evList.Add(data9);
|
|
var data10 = new FeeUnit();
|
|
data10.UNIT = "小时";
|
|
evList.Add(data10);
|
|
var data11 = new FeeUnit();
|
|
data11.UNIT = "个";
|
|
evList.Add(data11);
|
|
|
|
return evList;
|
|
}
|
|
|
|
public static bool ImportDetailData(HttpRequestBase request, DataTable table,string userid, string GID, out string msg, out List<CustTruckFeeTemplateDetail> headList)
|
|
{
|
|
var isSucess = false;
|
|
msg = "";
|
|
headList = new List<CustTruckFeeTemplateDetail>();
|
|
if (table == null) throw new ArgumentNullException("table");
|
|
|
|
var billNoList = new List<string>();
|
|
var i = 1;
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
foreach (DataRow row in table.Rows)
|
|
{
|
|
var PORTLOAD = Convert.ToString(row["启运地"]);
|
|
if (PORTLOAD != "")
|
|
{
|
|
var PORTDISCHARGE = Convert.ToString(row["目的地"]);
|
|
var UNITTYPE = Convert.ToString(row["计费标准"]);
|
|
var UNIT = Convert.ToString(row["车型"]);
|
|
var STARTWEIGHTSTR = Convert.ToString(row["计费标准起"]);
|
|
var ENDWEIGHTSTR = Convert.ToString(row["计费标准止"]);
|
|
var UNITPRICESTR = Convert.ToString(row["单价"]);
|
|
var REMARK = Convert.ToString(row["备注"]);
|
|
Decimal STARTWEIGHT = 0;
|
|
Decimal ENDWEIGHT = 0;
|
|
Decimal UNITPRICE = 0;
|
|
try
|
|
{
|
|
if (Convert.ToDecimal(STARTWEIGHTSTR) != 0)
|
|
STARTWEIGHT = Convert.ToDecimal(STARTWEIGHTSTR);
|
|
}
|
|
catch
|
|
{
|
|
// head.FREIGHT = 0;
|
|
}
|
|
try
|
|
{
|
|
if (Convert.ToDecimal(ENDWEIGHTSTR) != 0)
|
|
ENDWEIGHT = Convert.ToDecimal(ENDWEIGHTSTR);
|
|
}
|
|
catch
|
|
{
|
|
// head.FREIGHT = 0;
|
|
}
|
|
try
|
|
{
|
|
if (Convert.ToDecimal(UNITPRICESTR) != 0)
|
|
UNITPRICE = Convert.ToDecimal(UNITPRICESTR);
|
|
}
|
|
catch
|
|
{
|
|
// head.FREIGHT = 0;
|
|
}
|
|
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into Cust_Truck_feetemplatedetail (GID,TEMPLATEID,UNITTYPE,UNIT,UNITPRICE,STARTWEIGHT,ENDWEIGHT,REMARK,CREATEUSER,CREATETIME,LOADPORT,DISTPORT)
|
|
values (@GID,@TEMPLATEID,@UNITTYPE,@UNIT,@UNITPRICE,@STARTWEIGHT,@ENDWEIGHT,@REMARK,@CREATEUSER,@CREATETIME,@LOADPORT,@DISTPORT) ");
|
|
cmdInsert.Parameters.Clear();
|
|
|
|
|
|
var headdata = new CustTruckFeeTemplateDetail();
|
|
headdata.GID = Guid.NewGuid().ToString();
|
|
headdata.TEMPLATEID = GID;
|
|
headdata.UNITTYPE = UNITTYPE;
|
|
headdata.UNIT = UNIT;
|
|
headdata.STARTWEIGHT = STARTWEIGHT;
|
|
headdata.ENDWEIGHT = ENDWEIGHT;
|
|
headdata.REMARK = REMARK;
|
|
headdata.LOADPORT = PORTLOAD;
|
|
headdata.DISTPORT = PORTDISCHARGE;
|
|
headdata.CREATEUSER = userid;
|
|
headdata.CREATETIME = DateTime.Now.ToString();
|
|
|
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, headdata.GID);
|
|
db.AddInParameter(cmdInsert, "@TEMPLATEID", DbType.String, headdata.TEMPLATEID);
|
|
db.AddInParameter(cmdInsert, "@UNITTYPE", DbType.String, UNITTYPE);
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, UNIT);
|
|
db.AddInParameter(cmdInsert, "@UNITPRICE", DbType.Decimal, UNITPRICE);
|
|
db.AddInParameter(cmdInsert, "@STARTWEIGHT", DbType.Decimal, STARTWEIGHT);
|
|
db.AddInParameter(cmdInsert, "@ENDWEIGHT", DbType.Decimal, ENDWEIGHT);
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, REMARK);
|
|
db.AddInParameter(cmdInsert, "@LOADPORT", DbType.String, PORTLOAD);
|
|
db.AddInParameter(cmdInsert, "@DISTPORT", DbType.String, PORTDISCHARGE);
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString());
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
headList.Add(headdata);
|
|
}
|
|
|
|
isSucess = true;
|
|
i++;
|
|
|
|
|
|
}
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = msg + e.Message;
|
|
}
|
|
|
|
}
|
|
|
|
return isSucess;
|
|
}
|
|
|
|
|
|
#region 参照部分
|
|
|
|
static public int GetRdCount(string strCondition)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append(" Count(GID) AS CT ");
|
|
strSql.Append(" from Cust_Truck_feetemplate ");
|
|
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;
|
|
}
|
|
|
|
public static string GetRangDAStr(string tb, string userid, string usercode, string orgcode)
|
|
{
|
|
string str = "";
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
|
|
strSql.Append(" from VW_User_Authority ");
|
|
strSql.Append(" where [NAME]='modCustTruckFeeTemplate' 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")
|
|
{
|
|
if (tb == "index")
|
|
{
|
|
str = " CREATEUSER='" + userid + "'";
|
|
}
|
|
else
|
|
{
|
|
str = " UPPER(CORPID)='" + orgcode + "'";
|
|
}
|
|
}
|
|
else if (visiblerange == "2")
|
|
{
|
|
if (tb == "index")
|
|
{
|
|
str = " UPPER(CORPID)='" + orgcode + "'";
|
|
}
|
|
else
|
|
{
|
|
str = " UPPER(CORPID)='" + orgcode + "'";
|
|
}
|
|
|
|
}
|
|
else if (visiblerange == "1")
|
|
{
|
|
str = " UPPER(CORPID)='" + orgcode + "'";
|
|
}
|
|
|
|
return str;
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|