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.

865 lines
50 KiB
C#

10 months ago
using System;
using System.IO;
using System.Data;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsCwVouchersGlDAL;
using DSWeb.MvcShipping.Models.MsCwVouchersGl;
using DSWeb.MvcShipping.Models.MsCwVouitemsGl;
using DSWeb.MvcShipping.Helper;
using HcUtility.Comm;
using HcUtility.Core;
using System.Collections.Generic;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.DAL;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsCwVouchersGlController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
#region 查询
public ContentResult GetDataListHJ(int start, int limit, string sort, string condition)
{
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(Convert.ToString(Session["USERID"]));
var dataList = MsCwVouchersGlDAL.GetDataListHJ(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), strCwSTARTGID, sort);
int count = MsCwVouchersGlDAL.getHJTotalCount(condition, strCwSTARTGID, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string handle, string condition)
{
MsCwVouchersGl head = null;
head = MsCwVouchersGlDAL.GetData(condition, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetDetailList(string condition)
{
var dataList = MsCwVouchersGlDAL.GetDetailList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDataCwVVList(int start, int limit, string sort, string condition)
{
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(Convert.ToString(Session["USERID"]));
var dataList = MsCwVouchersGlDAL.GetDataCwVVList(start,limit,condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), strCwSTARTGID, sort);
int count = MsCwVouchersGlDAL.getTotalCount(condition, strCwSTARTGID, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDataVW(string handle, string condition)
{
MsCwVouchersVouitemsGl head = null;
head = MsCwVouchersGlDAL.GetDataVW(condition, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
//打印明细列表
public ContentResult GetDataListStr(string condition, string sort)
{
var dataListStr = MsCwVouchersGlDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
//打印合计列表
public ContentResult GetDataListStrHJ(string condition, string sort)
{
var dataListStr = MsCwVouchersGlDAL.GetDataListStrHJ(condition, Convert.ToString(Session["USERID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
#endregion
#region 明细表保存
public ContentResult SaveEdit(string opstatus, string data, string body, string DelBody)//, string data_v
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
string strCwACCDATE = BasicDataRefDAL.GetCwACCDATE(Convert.ToString(Session["USERID"]).Trim());
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(Convert.ToString(Session["USERID"]).Trim());
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
//var headData_v = JsonConvert.Deserialize<MsCwVouchersGl>(data_v);
var headData = JsonConvert.Deserialize<MsCwVouchersGl>(data);
var bodyList = JsonConvert.Deserialize<List<MsCwVouitemsGl>>(body);
var DelBodyList = JsonConvert.Deserialize<List<MsCwVouitemsGl>>(DelBody);
string ORDNO = "";
string oldVOUALLNO = "";
var isPost = true;
var errorstr = "";
#region 默认值
//headData.VOUNO = "";//月初清零
//headData.VKNO = "";//凭证字
//headData.VOUDATE = "";//凭证日期
//headData.ATTACHS = "";//附件(单据)数
headData.STARTGID = strCwSTARTGID;
ORDNO = headData.ORDNO.ToString().Trim();
headData.ACCYEAR = DateTime.Parse(headData.VOUDATE.ToString()).Year.ToString();//年
headData.ACCMONTH = DateTime.Parse(headData.VOUDATE.ToString()).Month.ToString();//月
if (headData.ACCMONTH.ToString().Length == 1)
{
headData.ACCMONTH = "0" + headData.ACCMONTH.ToString();//月
}
headData.PREPARED = Convert.ToString(Session["SHOWNAME"]).Trim();//制单人
headData.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人
headData.CREATETIME = DateTime.Now;//创建时间
headData.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次更新操作人
headData.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
#endregion
if (opstatus == "add")
{
#region 获取凭证号
string sVOUNOList = DSWeb.MvcShipping.DAL.MsBaseInfoDAL.MsBaseInfoDAL.GetCwVOUNO(headData.VKNO.ToString(), (headData.ACCYEAR + "-" + headData.ACCMONTH), Convert.ToString(Session["USERID"]));
string[] ayList = sVOUNOList.Trim().Split(new string[] { "~" }, StringSplitOptions.RemoveEmptyEntries);
headData.VOUNO = ayList[2].ToString();
string strVOUNO = ayList[3].ToString();
headData.VOUALLNO = headData.VKNO + headData.ACCYEAR + headData.ACCMONTH + strVOUNO;//年+月+自动生成编号=凭证号
#endregion
#region 其他默认值
ORDNO = "VOU" + Guid.NewGuid().ToString().Trim().Replace("-", "");
headData.ORDNO = ORDNO;//唯一编码 newid()
headData.AMTDR = 0;//本位币借方
headData.AMTCR = 0;//本位币贷方
headData.FCY = "RMB";//是否含有外币科目
headData.QTY = "";//是否含有数量科目
headData.VOUPROP = "";//凭证属性
headData.CHECKED = "";//审核人
headData.ENTERED = "";//记账人
headData.ERRMSG = "";//错误信息
headData.ISDELETE = false;//是否废除
headData.DELETEUSER = "";//废除操作人
//headData.DELETETIME = null;//废除时间
headData.ISEXPORT = false;//是否导出凭证
#endregion
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
oldVOUALLNO = T_ALL_DA.GetStrSQL("VOUALLNO", "select top 1 VOUALLNO from cw_vouchers_gl WITH(NOLOCK) where ORDNO='" + headData.ORDNO.ToString().Trim() + "'");
#region 获取凭证号
string strVOUNO = headData.VOUNO.ToString();
if (oldVOUALLNO.IndexOf(headData.VKNO.ToString()) < 0)
{
string sVOUNOList = DSWeb.MvcShipping.DAL.MsBaseInfoDAL.MsBaseInfoDAL.GetCwVOUNO(headData.VKNO.ToString(), (headData.ACCYEAR + "-" + headData.ACCMONTH), Convert.ToString(Session["USERID"]));
string[] ayList = sVOUNOList.Trim().Split(new string[] { "~" }, StringSplitOptions.RemoveEmptyEntries);
headData.VOUNO = ayList[2].ToString();
strVOUNO = ayList[3].ToString();
}
else
{
for (int i = 0; i < (4 - headData.VOUNO.ToString().Length); i++)
{
strVOUNO = "0" + strVOUNO;
}
}
headData.VOUALLNO = headData.VKNO + headData.ACCYEAR + headData.ACCMONTH + strVOUNO;//年+月+自动生成编号=凭证号
#endregion
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var issame = true;
var voustr = "";
if (headData.ISCOPY) {
voustr = T_ALL_DA.GetStrSQL("VOUALLNO", "select VOUALLNO from cw_vouchers_gl where COPYORDNO='"+headData.ORDNO+ "' AND ISCHECKED=1 ");//客户(系统)//varchar(18)
if (voustr != "") issame = false;
}
var headRowList = new List<MsCwVouitemsGl>();
decimal AMTDR_HJ = 0;
decimal AMTCR_HJ = 0;
if (bodyList != null)
{
int n = 1;
foreach (var enumValue in bodyList)
{
#region 默认值
MsCwVouitemsGl headRow = new MsCwVouitemsGl();
headRow.ORDNO = headData.ORDNO;
headRow.ITEMNO = n;//行号 = "";//int = "";//
headRow.EXPLAN = enumValue.EXPLAN;//摘要,规则生成 = "";//varchar = "";//(60)
//
#region 分解 会计科目 字符串
headRow.CUSTOMERNAME = "";//委托单位//Varchar20
headRow.SALE = "";//揽货人//varchar10
headRow.BLNO = enumValue.BLNO;//业务编号//varchar30
headRow.ITEMGID = "";//项目名称//varchar
headRow.DEPTGID = "";//项目名称//varchar
headRow.ISDEPTACC = false;//核算部门,按规则设置生成//bit
headRow.ISEMPLACC = false;//核算人员,按规则设置生成//bit
headRow.ISCORPACC = false;//核算客户,按规则设置生成//bit
headRow.ISITEMACC = false;//核算项目,按规则设置生成//bit
headRow.DEPTID = "";//部门(系统)//varchar(18)
headRow.EMPLID = "";//人员(系统)//varchar(18)
headRow.CORPID = "";//客户(系统)//varchar(18)
headRow.ITEMID = "";//项目编号//Varchar(50)
//
headRow.ACCID = enumValue.ACCID;//科目代码 = "";//varchar = "";//(16)
string sACCALL = enumValue.ACCALL.ToString().Trim();//会计科目字符串//varchar
int iACCALL2 = sACCALL.IndexOf("_");
int iACCALL = sACCALL.IndexOf("-");
if (iACCALL2 > iACCALL)
{
if (iACCALL > -1)
{
sACCALL = sACCALL.Substring(iACCALL + 1);
}
}
else
{
if (iACCALL2 == -1)
{
if (iACCALL > -1)
{
sACCALL = sACCALL.Substring(iACCALL + 1);
}
}
}
headRow.ACCALL = sACCALL.Trim();//会计科目字符串//varchar
string[] ayList = headRow.ACCALL.ToString().Trim().Split(new string[] { "▁" }, StringSplitOptions.RemoveEmptyEntries);
headRow.ACCNAME = ayList[0].ToString();//科目名称 varchar(60)
string strITEM = headRow.ACCNAME.ToString();//科目名称 varchar(60)
string sSQL2 = "select top 1 * from cw_accitems_gl WITH(NOLOCK) where [year]=SUBSTRING('" + strCwACCDATE + "',1,4) and ACCID='" + headRow.ACCID.ToString() + "' and [STARTGID]='" + strCwSTARTGID + "'";
DataSet ds = T_ALL_DA.GetAllSQL(sSQL2);
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
headRow.ACCID = ds.Tables[0].Rows[0]["ACCID"].ToString();//科目代码//varchar(16)
headRow.ACCNAME = ds.Tables[0].Rows[0]["ACCNAME"].ToString();//科目名称 varchar(60)
strITEM = headRow.ACCNAME.ToString();//科目名称 varchar(60)
if (ds.Tables[0].Rows[0]["ISCORPACC"].ToString() == "True")
{
strITEM += "▁CustNAME";//核算客户,按规则设置生成
}
if (ds.Tables[0].Rows[0]["ISDEPTACC"].ToString() == "True")
{
strITEM += "▁DeptName";//核算部门,按规则设置生成
}
if (ds.Tables[0].Rows[0]["ISEMPLACC"].ToString() == "True")
{
strITEM += "▁SALE";//核算人员,按规则设置生成
}
if (ds.Tables[0].Rows[0]["ISITEMACC"].ToString() == "True")
{
strITEM += "▁ITEMNAME";//核算项目,按规则设置生成
}
}
}
string[] ayItem = strITEM.Trim().Split(new string[] { "▁" }, StringSplitOptions.RemoveEmptyEntries);
for (var i = 1; i < ayList.Count(); i++)
{
if (ayItem[i].ToString() == "CustNAME")//委托单位
{
headRow.ISCORPACC = true;//核算客户,按规则设置生成//bit
headRow.CUSTOMERNAME = ayList[i].ToString();//委托单位//Varchar20
if (enumValue.AMTDR == 0)//借
{
sSQL2 = "select top 1 FARCODE from info_client WITH(NOLOCK) where SHORTNAME='" + ayList[i].ToString() + "'";
}
else//贷
{
sSQL2 = "select top 1 FAPCODE as FARCODE from info_client WITH(NOLOCK) where SHORTNAME='" + ayList[i].ToString() + "'";
}
headRow.CORPID = T_ALL_DA.GetStrSQL("FARCODE", sSQL2);//客户(系统)//varchar(18)
}
else if (ayItem[i].ToString() == "DeptName")
{
headRow.ISDEPTACC = true;//核算部门,按规则设置生成//bit
sSQL2 = "select top 1 FINANCESOFTCODE from sys_dept WITH(NOLOCK) where DEPTNAME='" + ayList[i].ToString() + "'";
headRow.DEPTID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", sSQL2);
sSQL2 = "select top 1 GID from sys_dept where DEPTNAME='" + ayList[i].ToString() + "'";
headRow.DEPTGID = T_ALL_DA.GetStrSQL("GID", sSQL2);
}
else if (ayItem[i].ToString() == "SALE")
{
headRow.ISEMPLACC = true;//核算人员,按规则设置生成//bit
headRow.SALE = ayList[i].ToString();//揽货人//varchar10
sSQL2 = "select top 1 FINANCESOFTCODE from user_baseinfo,[user] WITH(NOLOCK) where [user].GID=user_baseinfo.USERID and [user].SHOWNAME='" + ayList[i].ToString() + "'";
headRow.EMPLID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", sSQL2);//人员(系统)//varchar(18)
}
else if (ayItem[i].ToString() == "ITEMNAME")
{
headRow.ISITEMACC = true;//核算项目,按规则设置生成//bit
sSQL2 = "select top 1 FINANCESOFTCODE from cw_item WITH(NOLOCK) where [STARTGID]='" + strCwSTARTGID + "' and ITEMNAME='" + ayList[i].ToString() + "'";
headRow.ITEMID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", sSQL2);//项目编号//Varchar(50)
sSQL2 = "select top 1 GID from cw_item WITH(NOLOCK) where [STARTGID]='" + strCwSTARTGID + "' and ITEMNAME='" + ayList[i].ToString() + "'";
headRow.ITEMGID = T_ALL_DA.GetStrSQL("GID", sSQL2);//项目名称//varchar
}
}
#endregion
//
headRow.AMTDR = enumValue.AMTDR;//本位币借方金额(互斥) = "";//Numeric = "";//(18,2)
headRow.AMTCR = enumValue.AMTCR;//本位币贷方金额(互斥) = "";//Numeric = "";//(18,2)
headRow.DC = enumValue.DC;//本位币贷方金额(互斥) = "";//Numeric = "";//(18,2)
if (enumValue.DC == "借")
{
headRow.DC = "D";//科目借贷方向
}
else if (enumValue.DC == "贷")
{
headRow.DC = "C";//科目借贷方向
}
else if (enumValue.DC == "")
{
headRow.DC = "D";//科目借贷方向
}
headRow.FCYNO = "RMB";//外币编号usd = "";//varchar = "";//(8)
headRow.ISFCY = false;//是否外币 = "";//Bit = "";//
headRow.FCYEXRATE = 1;//汇率 = "";//Numeric = "";//(18,2)
if (enumValue.FCYNO.ToString().Trim() != "RMB" && enumValue.FCYNO.ToString().Trim() != "")
{
headData.FCY = enumValue.FCYNO.ToString().Trim();//是否含有外币科目
headRow.FCYNO = enumValue.FCYNO.ToString().Trim();//外币编号usd = "";//varchar = "";//(8)
headRow.ISFCY = true;//是否外币 = "";//Bit = "";//
headRow.FCYEXRATE = enumValue.FCYEXRATE;//汇率 = "";//Numeric = "";//(18,2)
if (enumValue.AMTCR == 0)
{
headRow.FCYDR = enumValue.FCYAMT;//外币借方金额 = "";//Numeric = "";//(18,2)
headRow.FCYCR = 0;//外币贷方金额 = "";//Numeric = "";//(18,2)
headRow.AMTDR = enumValue.AMTDR;//Decimal.Parse((enumValue.FCYAMT * enumValue.FCYEXRATE).ToString("#.##"));//本位币借方金额(互斥)//Numeric(18,2)
}
else
{
headRow.FCYDR = 0;//外币借方金额 = "";//Numeric = "";//(18,2)
headRow.FCYCR = enumValue.FCYAMT;//外币贷方金额 = "";//Numeric = "";//(18,2)
headRow.AMTCR = enumValue.AMTCR;//Decimal.Parse((enumValue.FCYAMT * enumValue.FCYEXRATE).ToString("#.##"));//本位币借方金额(互斥)//Numeric(18,2)
}
AMTDR_HJ += enumValue.AMTDR;
AMTCR_HJ += enumValue.AMTCR;
}
else
{
AMTDR_HJ += enumValue.AMTDR;
AMTCR_HJ += enumValue.AMTCR;
}
//
headRow.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人
headRow.CREATETIME = DateTime.Now;//创建时间
headRow.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次更新操作人
headRow.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
#endregion
//
if (enumValue.GID.ToString().Trim() == "*")//"add"
{
#region 默认值
string GID = Guid.NewGuid().ToString();
headRow.GID = GID;//唯一编码 newid() varchar (36)
headRow.ORDNO = headData.ORDNO;
headRow.PACCID = "";//父级科目代码 = "";//varchar = "";//(16)
headRow.PROPERTY = 0;//科目属性 = "";//int = "";//
headRow.GRADE = 0;//科目级别 = "";//int = "";//
headRow.QTYUNIT = "";//数量包装单位 = "";//varchar = "";//(10)
headRow.QTYDR = 0;//借方数量 = "";//Numeric = "";//(18,2)
headRow.QTYCR = 0;//贷方数量 = "";//Numeric = "";//(18,2)
headRow.PITEMID = 0;//父级项目编号 = "";//int = "";// 
headRow.FIELD1 = "";//预留字段1 = "";//varchar = "";//(10)
headRow.FIELD2 = "";//预留字段2 = "";//varchar = "";//(10)
headRow.FIELD3 = "";//预留字段3 = "";//varchar = "";//(20)
headRow.FIELD4 = "";//预留字段4 = "";//varchar = "";//(20)
headRow.FIELD5 = "";//预留字段5 = "";//varchar = "";//(20)
headRow.FIELD6 = "";//预留字段6 = "";//varchar = "";//(20)
headRow.FIELD7 = "";//预留字段7 = "";//varchar = "";//(60)
headRow.FIELD8 = "";//预留字段8 = "";//varchar = "";//(60)
headRow.FIELD9 = "";//预留字段9 = "";//varchar = "";//(60)
headRow.FIELD10 = "";//预留字段10 = "";//varchar = "";//(60)
headRow.ISSYS = true;//是否手动录入 = "";//Bit = "";//
headRow.FSETTLCODE = "";//结算方式 = "";//varchar = "";//(20)
headRow.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期
headRow.FSETTLENO = "";//财务辅助编号 = "";//varchar = "";//(20)
#endregion
headRow.DbOperationType = DbOperationType.DbotIns;
}
else//"edit"
{
headRow.GID = enumValue.GID.ToString().Trim();//唯一编码
headRow.DbOperationType = DbOperationType.DbotUpd;
headRow.ModelUIStatus = "E";
}
headRowList.Add(headRow);
n++;
}
}
//
if (isPost)
{
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
if (result.Success == true)
{
#region 明细表保存
//删除列表中的多余数据
if (DelBodyList != null)
{
foreach (var enumValue in DelBodyList)
{
DBResult result1 = MsCwVouchersGlDAL.DeleteDetail(enumValue);
}
}
//添加、修改数据
if (bodyList != null)
{
foreach (var enumValue in headRowList)
{
modb = new ModelObjectDB();
result = modb.Save(enumValue);
if (result.Message.ToString().IndexOf("插入重复键") > -1)
{
errorstr += "重复数据不再重复插入!";
//var jsonRespose = new JsonResponse { Success = false, Message = "重复,不允许保存!" };
//return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
if (headData.ISCOPY&& issame) {
var sSQLitems = "";
if (enumValue.DbOperationType ==DbOperationType.DbotIns) {
sSQLitems = "INSERT INTO [cw_vouitems_gl] ([GID],[ORDNO],[ITEMNO],[ACCID],[PACCID],[ACCNAME],[PROPERTY],[GRADE],[DC],[AMTDR],[AMTCR]"
+",[ISFCY],[FCYNO],[FCYEXRATE],[FCYDR],[FCYCR],[QTYUNIT],[QTYDR],[QTYCR],[EXPLAN],[ISDEPTACC],[ISEMPLACC],[ISCORPACC],[ISITEMACC],[DEPTID],[EMPLID],[CORPID],[PITEMID],[ITEMID],[FIELD10]"
+",[FIELD9],[FIELD8],[FIELD7],[FIELD6],[FIELD5],[FIELD4],[FIELD3],[FIELD2],[FIELD1],[ISSYS],[FSETTLCODE],[FSETTLENO],[MODIFIEDUSER],[MODIFIEDTIME],[CUSTOMERNAME],[SALE],[BLNO],[ITEMGID]"
+",[DEPTGID],[ACCALL],[FSETTLDATE],[CREATEUSER],[CREATETIME],[COPYGID]) SELECT NEWID(),(SELECT TOP 1 ORDNO FROM cw_vouchers_gl WHERE COPYORDNO='"+headData.ORDNO+"'),[ITEMNO],[ACCID],[PACCID],[ACCNAME],[PROPERTY],[GRADE],[DC],[AMTDR]"
+ ",[AMTCR],[ISFCY],[FCYNO],[FCYEXRATE],[FCYDR],[FCYCR],[QTYUNIT],[QTYDR],[QTYCR],[EXPLAN],[ISDEPTACC],[ISEMPLACC],[ISCORPACC],[ISITEMACC]"
+ ",[DEPTID],[EMPLID],[CORPID],[PITEMID],[ITEMID],[FIELD10],[FIELD9],[FIELD8],[FIELD7],[FIELD6],[FIELD5],[FIELD4],[FIELD3],[FIELD2]"
+ ",[FIELD1],[ISSYS],[FSETTLCODE],[FSETTLENO],[MODIFIEDUSER],[MODIFIEDTIME],[CUSTOMERNAME],[SALE],[BLNO],[ITEMGID],[DEPTGID],[ACCALL]"
+ ",[FSETTLDATE],'" + enumValue.CREATEUSER + "',GETDATE(),GID FROM [cw_vouitems_gl] WHERE GID='" + enumValue.GID + "' and isnull((SELECT TOP 1 ORDNO FROM cw_vouchers_gl WHERE COPYORDNO='" + headData.ORDNO + "'),'')<>'' ";
} else {
sSQLitems = "UPDATE [cw_vouitems_gl] SET [ITEMNO]=g.ITEMNO,[ACCID]=g.ACCID,[PACCID]=g.PACCID"
+ " ,[ACCNAME]=g.ACCNAME,[PROPERTY]=g.PROPERTY,[GRADE]=g.GRADE,[DC]=g.DC,[AMTDR]=g.AMTDR"
+ ",[AMTCR]=g.AMTCR,[ISFCY]=g.ISFCY,[FCYNO]=g.FCYNO,[FCYEXRATE]=g.FCYEXRATE,[FCYDR]=g.FCYDR,[FCYCR]=g.FCYCR,[QTYUNIT]=g.QTYUNIT,[QTYDR]=g.QTYDR,[QTYCR]=g.QTYCR,[EXPLAN]=g.EXPLAN,[ISDEPTACC]=g.ISDEPTACC,[ISEMPLACC]=g.ISEMPLACC,[ISCORPACC]=g.ISCORPACC,[ISITEMACC]=g.ISITEMACC"
+ ",[DEPTID]=g.DEPTID,[EMPLID]=g.EMPLID,[CORPID]=g.CORPID,[PITEMID]=g.PITEMID,[ITEMID]=g.ITEMID,[FIELD10]=g.FIELD10,[FIELD9]=g.FIELD9,[FIELD8]=g.FIELD8,[FIELD7]=g.FIELD7,[FIELD6]=g.FIELD6,[FIELD5]=g.FIELD5,[FIELD4]=g.FIELD4,[FIELD3]=g.FIELD3,[FIELD2]=g.FIELD2"
+ ",[FIELD1]=g.FIELD1,[ISSYS]=g.ISSYS,[FSETTLCODE]=g.FSETTLCODE,[FSETTLENO]=g.FSETTLENO,[MODIFIEDUSER]=g.MODIFIEDUSER,[MODIFIEDTIME]=g.MODIFIEDTIME,[CUSTOMERNAME]=g.CUSTOMERNAME,[SALE]=g.SALE,[BLNO]=g.BLNO,[ITEMGID]=g.ITEMGID,[DEPTGID]=g.DEPTGID,[ACCALL]=g.ACCALL"
+ ",[FSETTLDATE]=g.FSETTLDATE FROM [cw_vouitems_gl],[cw_vouitems_gl] g WHERE [cw_vouitems_gl].COPYGID='" + enumValue.GID + "' AND g.GID='"+ enumValue.GID+"'";
}
T_ALL_DA.GetExecuteSqlCommand(sSQLitems);
}
}
//
string sSQL = "update cw_vouchers_gl set AMTDR=" + AMTDR_HJ + ",AMTCR=" + AMTCR_HJ + " where ORDNO='" + headData.ORDNO.ToString().Trim() + "'";
if (headData.FCY.ToString().Trim() != "RMB")
{
sSQL = "update cw_vouchers_gl set AMTDR=" + AMTDR_HJ + ",AMTCR=" + AMTCR_HJ + ",FCY='" + headData.FCY + "' where ORDNO='" + headData.ORDNO.ToString().Trim() + "'";
}
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
if (headData.ISCOPY&& issame) {
sSQL = "update cw_vouchers_gl set VOUNO='"+headData.VOUNO+ "',VKNO='" + headData.VKNO + "',VOUALLNO='" + headData.VOUALLNO + "',AMTDR=" + AMTDR_HJ + ",AMTCR=" + AMTCR_HJ + " where COPYORDNO='" + headData.ORDNO.ToString().Trim() + "'";
if (headData.FCY.ToString().Trim() != "RMB")
{
sSQL = "update cw_vouchers_gl set VOUNO='" + headData.VOUNO + "',VKNO='" + headData.VKNO + "',VOUALLNO='" + headData.VOUALLNO + "',AMTDR=" + AMTDR_HJ + ",AMTCR=" + AMTCR_HJ + ",FCY='" + headData.FCY + "' where COPYORDNO='" + headData.ORDNO.ToString().Trim() + "'";
}
bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
//
if (oldVOUALLNO.Trim() != "")
{
sSQL = "UPDATE cw_vouno_bs_gl SET VOUALLNO='" + headData.VOUALLNO.ToString() + "' where ORDNO in ('" + headData.ORDNO.ToString() + "') and STARTGID='" + strCwSTARTGID + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
//
}
#endregion
//补号表当前凭证改为删除状态
string sls = "UPDATE [code_fill_serialno] SET [ISDELETE]=1,[DELETEUSER]='" + Convert.ToString(Session["USERID"]).Trim() + "',[DELETETIME]=GETDATE() where [SERIALNO]='" + headData.VOUALLNO.ToString() + "' and STARTGID='" + strCwSTARTGID + "'";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(sls);
}
if (!issame)
{
var jsonRespose = new JsonResponse { Success = false, Message ="已保存,但分账套:"+ voustr + ",已记账不允许修改,请手动修改!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCwVouchersGlDAL.GetData("ORDNO='" + ORDNO + "'", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr + "重复,不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#endregion
#region 删除
public ContentResult Delete(string gids)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var voustr = T_ALL_DA.GetStrSQL("VOUALLNO", "select top 1 VOUALLNO from cw_vouchers_gl where COPYORDNO in ('" + gids.Replace(",", "','") + "') AND ISCHECKED=1 ");//客户(系统)//varchar(18)
if (voustr != "")
{
var jsonRespose = new JsonResponse { Success = false, Message = "分账套凭证:" + voustr + ",已记账不允许修改,请手动先手动删除分账套凭证!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
DBResult result = MsCwVouchersGlDAL.Delete(gids, Convert.ToString(Session["USERID"]).Trim());
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
3 months ago
public ContentResult SetNotExp(string gids)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
T_ALL_DA.GetExecuteSqlCommand("update cw_vouchers_gl set ISEXPORT=0,EXPVOUNO='' where ORDNO in ('" + gids.Replace(",", "','") + "') ");//客户(系统)//varchar(18)
var jsonRespose = new JsonResponse { Success = true, Message = "已更新!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
10 months ago
public ContentResult DeleteDetail(string data)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var head = JsonConvert.Deserialize<MsCwVouitemsGl>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(head);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 根据币别,获取汇率值
public ContentResult GetFCYEXRATE(string FCY, string LINKGID)
{
var strList = MsCwVouchersGlDAL.GetFCYEXRATE(FCY, LINKGID, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
if (strList.Trim() == "-1")
{
var json = JsonConvert.Serialize(new { Success = false, Message = "请先设置对应的币别信息!", data = "" });
return new ContentResult() { Content = json };
}
else
{
var json = JsonConvert.Serialize(new { Success = true, Message = "操作成功!", data = strList });
return new ContentResult() { Content = json };
}
}
public ContentResult GetFCYEXRATEBYVOUDATE(string FCY, string LINKGID,string VOUDATE)
{
var strList = MsCwVouchersGlDAL.GetFCYEXRATEVOUDATE(FCY, LINKGID, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), VOUDATE);
if (strList.Trim() == "-1")
{
var json = JsonConvert.Serialize(new { Success = false, Message = "请先设置对应的币别信息!", data = "" });
return new ContentResult() { Content = json };
}
else
{
var json = JsonConvert.Serialize(new { Success = true, Message = "操作成功!", data = strList });
return new ContentResult() { Content = json };
}
}
#endregion
#region 审核/返审
public ContentResult setISCHECKED(string gids, string iTYPE, int iOK, int iSkip)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
DBResult result = MsCwVouchersGlDAL.setISCHECKED(gids, iTYPE, iOK, iSkip, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 1.上一条 / 2.下一条
public ContentResult setPrevious(int iTYPE, string ORDNO, string strCondition)
{
DBResult result = MsCwVouchersGlDAL.setPrevious(iTYPE, ORDNO, strCondition, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 是否已经维护财务代码
public ContentResult GetISFINANCESOFTCODE(string TYPE, string VALUE)
{
var strList = MsCwVouchersGlDAL.GetISFINANCESOFTCODE(TYPE, VALUE, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
if (strList.Trim() == "-1")
{
var json = JsonConvert.Serialize(new { Success = false, Message = "请先设置对应的财务代码!", data = "" });
return new ContentResult() { Content = json };
}
else
{
var json = JsonConvert.Serialize(new { Success = true, Message = "操作成功!", data = strList });
return new ContentResult() { Content = json };
}
}
#endregion
#region 是否导出数据
public ContentResult getIsExport(string condition, string gids)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
DBResult result = MsCwVouchersGlDAL.getIsExport(condition, gids, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 是否复制到其他账套
public ContentResult CopyVouToOther(string STARTGID, string gids)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
DBResult result = MsCwVouchersGlDAL.CopyVouToOther(STARTGID, gids, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]).Trim());
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 导出财务接口
public ContentResult setExcelReportGl(string strCondition, string gids)
{
var result = new DBResult();
string sSQL = "";
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(Convert.ToString(Session["USERID"]).Trim());
T_ALL_DA T_ALL_DA = new T_ALL_DA();
//帐套设置
sSQL = "SELECT top 1 * from cw_design_gl where STARTGID='" + strCwSTARTGID + "'";
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
if (ds == null)
{
result.Data = "";
result.Success = false;
result.Message = "请先设置帐套信息!";
var jsonRespose2 = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Data };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
string sgids = "'" + gids.Trim().Replace(",", "','") + "'";
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = " and " + strCondition;
}
if (gids.Trim() != "")
{
strCondition += " and ORDNO in (" + sgids + ")";
}
strCondition += " and STARTGID='" + strCwSTARTGID + "'";
if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "10")
{
strCondition = " 1=1 " + strCondition;
result = MsCwVouchersGlDAL.setExcelReportGlJDYUN(strCondition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), strCwSTARTGID);
result.Data = "";
7 months ago
}
if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "15")
{
strCondition = " 1=1 " + strCondition;
result = MsCwVouchersGlDAL.setExcelReportGlU8YUN(strCondition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), strCwSTARTGID);
result.Data = "";
10 months ago
}
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "13")
{
var templatepath = Server.MapPath("../../EDIFiles");
strCondition = " 1=1 " + strCondition;
result = MsCwVouchersGlDAL.setExcelReportGlinSuite(strCondition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), strCwSTARTGID, templatepath);
result.Data = "";
}
else
{
//
var sPath = Server.MapPath("../../Reports/dbf");
if (!Directory.Exists(sPath))
{
Directory.CreateDirectory(sPath);
}
var filename = "";
var errostr = "";
if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "1")//1.金蝶迷你
{
DBResult expresult = MsCwVouchersGlDAL.setExcelReportGlMN(strCondition, sPath);
filename = expresult.Data.ToString();
errostr = expresult.Message.ToString();
}
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "2")//2.金蝶标准
{
DBResult expresult = MsCwVouchersGlDAL.setExcelReportGlBZ(strCondition, sPath);
filename = expresult.Data.ToString();
errostr = expresult.Message.ToString();
}
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "3")//3.金蝶k3
{
DBResult expresult = MsCwVouchersGlDAL.setExcelReportGlK3(strCondition, sPath);
filename = expresult.Data.ToString();
errostr = expresult.Message.ToString();
}
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "4")//4.用友U8
{
filename = MsCwVouchersGlDAL.setExcelReportGlU8(strCondition, ds, sPath, Convert.ToString(Session["COMPANYID"]));
}
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "5")//5.浪潮
{
}
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "6")//6.SyBase
{
}
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "7")//7.用友NC
{
filename = MsCwVouchersGlDAL.setExcelReportGlNC(strCondition, ds, sPath, Convert.ToString(Session["COMPANYID"]));
}
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "8")//8.金蝶专业
{
DBResult expresult = MsCwVouchersGlDAL.setExcelReportGlZY(strCondition, sPath);
filename = expresult.Data.ToString();
errostr = expresult.Message.ToString();
}
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "12")//8.金蝶专业
{
DBResult expresult = MsCwVouchersGlDAL.setExcelReportGlZY2(strCondition, sPath);
filename = expresult.Data.ToString();
errostr = expresult.Message.ToString();
}
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "9")//3.金蝶k3
{
DBResult expresult = MsCwVouchersGlDAL.setExcelReportGlK32(strCondition, sPath);
filename = expresult.Data.ToString();
errostr = expresult.Message.ToString();
}
7 months ago
//else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "11")//11.金蝶k/3 wise
//{
// DBResult expresult = MsCwVouchersGlDAL.setExcelReportGlK3wise(strCondition, sPath);
// filename = expresult.Data.ToString();
// errostr = expresult.Message.ToString();
//}
10 months ago
//
if (filename == "")
{
result.Data = "";
result.Success = false;
result.Message = "凭证模板文件缺失,请联系管理员!";
var jsonRespose2 = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Data };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
else if (filename == "-1")
{
result.Data = "";
result.Success = false;
result.Message = "导出凭证出错,请重试!" + errostr;
var jsonRespose2 = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Data };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
filename = Path.GetFileName(filename);
result.Data = "../../Reports/dbf/" + filename;
result.Success = true;
result.Message = filename;
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Data };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 根据上传删除的附件数更新凭证附单据张数需求编号SR2017062800004
public ContentResult setAttachs(string sORDNO)
{
DBResult result = MsCwVouchersGlDAL.setAttachs(sORDNO);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 查询空凭证号
public ContentResult GetNoVKNO(string accdatefr, string accdateto)
{
DBResult result = MsCwVouchersGlDAL.GetNoVKNO(accdatefr, accdateto, Convert.ToString(Session["USERID"]).Trim(), Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
}
}