|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsCwAccitemsDaterp;
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsCwAccitemsDaterp
|
|
|
|
|
{
|
|
|
|
|
public class MsCwAccitemsDaterpDAL
|
|
|
|
|
{
|
|
|
|
|
#region Inquery DataList
|
|
|
|
|
|
|
|
|
|
static public List<CwAccitemsDateRp> GetDataList(string strCondition, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append("GID,ACCDATE,OPDATE,NOSAVERMBAMT,NOSAVEUSDAMT,GIFTAMT,ENTERTAINMENTAMT,TRAVELLINGAMT,OFFICESUPPLIESAMT,AUTOREPAIRAMT,ADPRINTINGAMT,CREATEUSER,CREATETIME");
|
|
|
|
|
strSql.Append(",(select ShowName from [user] where GID=cw_accitems_daterp.CREATEUSER) as CREATEUSERREF");
|
|
|
|
|
strSql.Append(" from cw_accitems_daterp ");
|
|
|
|
|
|
|
|
|
|
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 CwAccitemsDateRp GetData(string condition)
|
|
|
|
|
{
|
|
|
|
|
CwAccitemsDateRp data = null;
|
|
|
|
|
var list = GetDataList(condition);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
data = list[0];
|
|
|
|
|
|
|
|
|
|
if (data == null)
|
|
|
|
|
{
|
|
|
|
|
data = new CwAccitemsDateRp();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<CwAccitemsDateRp> SetData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<CwAccitemsDateRp>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
CwAccitemsDateRp data = new CwAccitemsDateRp();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
|
|
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
|
|
|
|
|
if (reader["OPDATE"] != DBNull.Value)
|
|
|
|
|
data.OPDATE = Convert.ToDateTime(reader["OPDATE"]).ToString("yyyy-MM-dd");
|
|
|
|
|
if (reader["NOSAVERMBAMT"] != DBNull.Value)
|
|
|
|
|
data.NOSAVERMBAMT = Convert.ToDecimal(reader["NOSAVERMBAMT"]);
|
|
|
|
|
if (reader["NOSAVEUSDAMT"] != DBNull.Value)
|
|
|
|
|
data.NOSAVEUSDAMT = Convert.ToDecimal(reader["NOSAVEUSDAMT"]);
|
|
|
|
|
|
|
|
|
|
if (reader["GIFTAMT"] != DBNull.Value)
|
|
|
|
|
data.GIFTAMT = Convert.ToDecimal(reader["GIFTAMT"]);
|
|
|
|
|
if (reader["ENTERTAINMENTAMT"] != DBNull.Value)
|
|
|
|
|
data.ENTERTAINMENTAMT = Convert.ToDecimal(reader["ENTERTAINMENTAMT"]);
|
|
|
|
|
if (reader["TRAVELLINGAMT"] != DBNull.Value)
|
|
|
|
|
data.TRAVELLINGAMT = Convert.ToDecimal(reader["TRAVELLINGAMT"]);
|
|
|
|
|
if (reader["OFFICESUPPLIESAMT"] != DBNull.Value)
|
|
|
|
|
data.OFFICESUPPLIESAMT = Convert.ToDecimal(reader["OFFICESUPPLIESAMT"]);
|
|
|
|
|
if (reader["AUTOREPAIRAMT"] != DBNull.Value)
|
|
|
|
|
data.AUTOREPAIRAMT = Convert.ToDecimal(reader["AUTOREPAIRAMT"]);
|
|
|
|
|
if (reader["ADPRINTINGAMT"] != DBNull.Value)
|
|
|
|
|
data.ADPRINTINGAMT = Convert.ToDecimal(reader["ADPRINTINGAMT"]);
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
static public string GetDataListStr(string strCondition, string userid, string usercode, string orgcode, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append("GID,ACCDATE,OPDATE,NOSAVERMBAMT,NOSAVEUSDAMT,ENTERTAINMENTAMT,TRAVELLINGAMT,OFFICESUPPLIESAMT,AUTOREPAIRAMT,ADPRINTINGAMT,CREATEUSER,CREATETIME");
|
|
|
|
|
strSql.Append(",(select ShowName from [user] where GID=cw_accitems_daterp.CREATEUSER) as CREATEUSERREF");
|
|
|
|
|
strSql.Append(" from cw_accitems_daterp ");
|
|
|
|
|
|
|
|
|
|
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 strSql.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public List<CwAccitemsDateRpDetail> GetBodyList(string strCondition, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("select GID,LINKGID,ACCNAME,AMTDR,AMTCR,USDAMTDR,USDAMTCR,HKDAMTDR,HKDAMTCR");
|
|
|
|
|
strSql.Append(" from cw_accitems_daterp_detail ");
|
|
|
|
|
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 ACCNAME ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SetBodyData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public List<CwAccitemsDateRpDetail> GetBodyAllList(string strCondition, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("select GID,LINKGID,ACCNAME,AMTDR,AMTCR,USDAMTDR,USDAMTCR,HKDAMTDR,HKDAMTCR");
|
|
|
|
|
strSql.Append(" from cw_accitems_daterp_detail ");
|
|
|
|
|
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 ACCID ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SetBodyData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<CwAccitemsDateRpDetail> SetBodyData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var bodyList = new List<CwAccitemsDateRpDetail>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
CwAccitemsDateRpDetail data = new CwAccitemsDateRpDetail();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
|
|
data.LINKGID = Convert.ToString(reader["LINKGID"]);
|
|
|
|
|
data.ACCNAME = Convert.ToString(reader["ACCNAME"]);
|
|
|
|
|
if (reader["AMTDR"] != DBNull.Value)
|
|
|
|
|
data.AMTDR = Convert.ToDecimal(reader["AMTDR"]);
|
|
|
|
|
if (reader["AMTCR"] != DBNull.Value)
|
|
|
|
|
data.AMTCR = Convert.ToDecimal(reader["AMTCR"]);
|
|
|
|
|
if (reader["USDAMTDR"] != DBNull.Value)
|
|
|
|
|
data.USDAMTDR = Convert.ToDecimal(reader["USDAMTDR"]);
|
|
|
|
|
if (reader["USDAMTCR"] != DBNull.Value)
|
|
|
|
|
data.USDAMTCR = Convert.ToDecimal(reader["USDAMTCR"]);
|
|
|
|
|
if (reader["HKDAMTDR"] != DBNull.Value)
|
|
|
|
|
data.HKDAMTDR = Convert.ToDecimal(reader["HKDAMTDR"]);
|
|
|
|
|
if (reader["HKDAMTCR"] != DBNull.Value)
|
|
|
|
|
data.HKDAMTCR = Convert.ToDecimal(reader["HKDAMTCR"]);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
bodyList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bodyList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DBResult SaveDetail(CwAccitemsDateRp headData, List<CwAccitemsDateRpDetail> bodyList, 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("delete from cw_accitems_daterp_detail where LINKGID='" + headData.GID + "'");
|
|
|
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
|
|
|
|
|
|
var cmdInsert =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"insert into cw_accitems_daterp_detail (GID,LINKGID,ACCNAME,AMTDR,AMTCR,USDAMTDR,USDAMTCR,HKDAMTDR,HKDAMTCR)
|
|
|
|
|
values (@GID,@LINKGID,@ACCNAME,@AMTDR,@AMTCR,@USDAMTDR,@USDAMTCR,@HKDAMTDR,@HKDAMTCR) ");
|
|
|
|
|
|
|
|
|
|
if (bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var enumValue in bodyList)
|
|
|
|
|
{
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
|
|
|
|
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
|
|
|
db.AddInParameter(cmdInsert, "@LINKGID", DbType.String,headData.GID);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@ACCNAME", DbType.String, enumValue.ACCNAME);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@AMTDR", DbType.Decimal, enumValue.AMTDR);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@AMTCR", DbType.String, enumValue.AMTCR);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@USDAMTDR", DbType.Decimal, enumValue.USDAMTDR);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@USDAMTCR", DbType.String, enumValue.USDAMTCR);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@HKDAMTDR", DbType.Decimal, enumValue.HKDAMTDR);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@HKDAMTCR", DbType.String, enumValue.HKDAMTCR);
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "保存出现错误,请重试或联系系统管理员"+e.Message;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "保存成功";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DBResult DeleteDetail(CwAccitemsDateRp 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 cw_accitems_daterp where GID='" + headData.GID + "'");
|
|
|
|
|
db.ExecuteNonQuery(cmd, tran);
|
|
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete from cw_accitems_daterp_detail where LINKGID='" + 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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]='modCodeFeeTemplateSet' 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
|
|
|
|
|
}
|
|
|
|
|
}
|