|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsCwAccitemsGlDAL;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsCwAccitemsGl;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsCwGenlegAccitemsDAL;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsCwGenlegAccitems;
|
|
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using HcUtility.Core;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
|
|
{
|
|
|
|
|
[JsonRequestBehavior]
|
|
|
|
|
public class MsCwAccitemsGlController : Controller
|
|
|
|
|
{
|
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
public ActionResult Edit()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 查询
|
|
|
|
|
public string GetDataList(string PACCGID, string condition)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(PACCGID))
|
|
|
|
|
{
|
|
|
|
|
condition += " and PACCGID='" + PACCGID + "'";
|
|
|
|
|
}
|
|
|
|
|
var dataList = MsCwAccitemsGlDAL.GetDataList(condition, Convert.ToString(Session["USERID"]));
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
|
|
|
return json;
|
|
|
|
|
//return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult GetDataListZC(string PACCGID, string condition)
|
|
|
|
|
{
|
|
|
|
|
PACCGID = PACCGID.Replace("root", "ZC");
|
|
|
|
|
var json = GetDataList(PACCGID, condition);
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult GetDataListFZ(string PACCGID, string condition)
|
|
|
|
|
{
|
|
|
|
|
PACCGID = PACCGID.Replace("root", "FZ");
|
|
|
|
|
var json = GetDataList(PACCGID, condition);
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult GetDataListGT(string PACCGID, string condition)
|
|
|
|
|
{
|
|
|
|
|
PACCGID = PACCGID.Replace("root", "GT");
|
|
|
|
|
var json = GetDataList(PACCGID, condition);
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult GetDataListQY(string PACCGID, string condition)
|
|
|
|
|
{
|
|
|
|
|
PACCGID = PACCGID.Replace("root", "QY");
|
|
|
|
|
var json = GetDataList(PACCGID, condition);
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult GetDataListCB(string PACCGID, string condition)
|
|
|
|
|
{
|
|
|
|
|
PACCGID = PACCGID.Replace("root", "CB");
|
|
|
|
|
var json = GetDataList(PACCGID, condition);
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult GetDataListSY(string PACCGID, string condition)
|
|
|
|
|
{
|
|
|
|
|
PACCGID = PACCGID.Replace("root", "SY");
|
|
|
|
|
var json = GetDataList(PACCGID, condition);
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult GetData(string handle, string condition)
|
|
|
|
|
{
|
|
|
|
|
MsCwAccitemsGl head = null;
|
|
|
|
|
if (handle == "edit")
|
|
|
|
|
{
|
|
|
|
|
head = MsCwAccitemsGlDAL.GetData(condition, Convert.ToString(Session["USERID"]));
|
|
|
|
|
}
|
|
|
|
|
if (head == null)
|
|
|
|
|
{
|
|
|
|
|
head = new MsCwAccitemsGl();
|
|
|
|
|
}
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存
|
|
|
|
|
public ContentResult Save(string opstatus, string data, string optype)
|
|
|
|
|
{
|
|
|
|
|
#region 登录信息是否超时
|
|
|
|
|
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) };
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 默认值
|
|
|
|
|
List<MsCwAccitemsGl> dataListOld = null;
|
|
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
|
var headData = JsonConvert.Deserialize<MsCwAccitemsGl>(data);
|
|
|
|
|
var isPost = true;
|
|
|
|
|
string strCwACCDATE = BasicDataRefDAL.GetCwACCDATE(Convert.ToString(Session["USERID"]).Trim());
|
|
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(Convert.ToString(Session["USERID"]).Trim());
|
|
|
|
|
string sYEAR = DateTime.Parse(strCwACCDATE + "-01").Year.ToString();
|
|
|
|
|
string sMONTH = DateTime.Parse(strCwACCDATE + "-01").Month.ToString();
|
|
|
|
|
if (sMONTH.Length == 1)
|
|
|
|
|
{
|
|
|
|
|
sMONTH = "0" + sMONTH;
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
headData.STARTGID = strCwSTARTGID;
|
|
|
|
|
if (headData.PACCID == null)
|
|
|
|
|
{
|
|
|
|
|
headData.PACCID = "";
|
|
|
|
|
if (headData.ACCATTRIBUTE.ToString().Trim() == "资产")
|
|
|
|
|
{
|
|
|
|
|
headData.PACCGID = "ZC";
|
|
|
|
|
}
|
|
|
|
|
else if (headData.ACCATTRIBUTE.ToString().Trim() == "负债")
|
|
|
|
|
{
|
|
|
|
|
headData.PACCGID = "FZ";
|
|
|
|
|
}
|
|
|
|
|
else if (headData.ACCATTRIBUTE.ToString().Trim() == "共同")
|
|
|
|
|
{
|
|
|
|
|
headData.PACCGID = "GT";
|
|
|
|
|
}
|
|
|
|
|
else if (headData.ACCATTRIBUTE.ToString().Trim() == "权益")
|
|
|
|
|
{
|
|
|
|
|
headData.PACCGID = "QY";
|
|
|
|
|
}
|
|
|
|
|
else if (headData.ACCATTRIBUTE.ToString().Trim() == "成本")
|
|
|
|
|
{
|
|
|
|
|
headData.PACCGID = "CB";
|
|
|
|
|
}
|
|
|
|
|
else if (headData.ACCATTRIBUTE.ToString().Trim() == "损益")
|
|
|
|
|
{
|
|
|
|
|
headData.PACCGID = "SY";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (headData.PACCID.ToString().Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
headData.PACCID = "";
|
|
|
|
|
if (headData.ACCATTRIBUTE.ToString().Trim() == "资产")
|
|
|
|
|
{
|
|
|
|
|
headData.PACCGID = "ZC";
|
|
|
|
|
}
|
|
|
|
|
else if (headData.ACCATTRIBUTE.ToString().Trim() == "负债")
|
|
|
|
|
{
|
|
|
|
|
headData.PACCGID = "FZ";
|
|
|
|
|
}
|
|
|
|
|
else if (headData.ACCATTRIBUTE.ToString().Trim() == "共同")
|
|
|
|
|
{
|
|
|
|
|
headData.PACCGID = "GT";
|
|
|
|
|
}
|
|
|
|
|
else if (headData.ACCATTRIBUTE.ToString().Trim() == "权益")
|
|
|
|
|
{
|
|
|
|
|
headData.PACCGID = "QY";
|
|
|
|
|
}
|
|
|
|
|
else if (headData.ACCATTRIBUTE.ToString().Trim() == "成本")
|
|
|
|
|
{
|
|
|
|
|
headData.PACCGID = "CB";
|
|
|
|
|
}
|
|
|
|
|
else if (headData.ACCATTRIBUTE.ToString().Trim() == "损益")
|
|
|
|
|
{
|
|
|
|
|
headData.PACCGID = "SY";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string PACCGID = T_ALL_DA.GetStrSQL("GID", "select top 1 isnull(GID,0) as GID from cw_accitems_gl where ACCID='" + headData.PACCID.ToString().Trim() + "' and [YEAR]='" + sYEAR + "' and [STARTGID]='" + strCwSTARTGID + "'");
|
|
|
|
|
headData.PACCGID = PACCGID.Trim();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int icount = MsCwGenlegAccitemsDAL.GetISENABLE(Convert.ToString(Session["USERID"]).Trim());//判断是否有未入账的数据
|
|
|
|
|
if (icount == 0)
|
|
|
|
|
{
|
|
|
|
|
icount = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
icount = 0;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if (opstatus == "add")
|
|
|
|
|
{
|
|
|
|
|
#region 默认值
|
|
|
|
|
headData.GID = Guid.NewGuid().ToString();
|
|
|
|
|
//headData.YEAR = DateTime.Now.Year.ToString();
|
|
|
|
|
//headData.MONTH = DateTime.Now.Month.ToString("##");
|
|
|
|
|
//if (DateTime.Now.Month.ToString().Length == 1)
|
|
|
|
|
//{
|
|
|
|
|
// headData.MONTH = "0" + DateTime.Now.Month.ToString();
|
|
|
|
|
//}
|
|
|
|
|
headData.YEAR = sYEAR;
|
|
|
|
|
headData.MONTH = sMONTH;
|
|
|
|
|
headData.DETAILED = true;
|
|
|
|
|
headData.ISENABLE = (icount == 0 ? false : true);
|
|
|
|
|
#endregion
|
|
|
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
|
|
|
}
|
|
|
|
|
else if (opstatus == "edit")
|
|
|
|
|
{
|
|
|
|
|
//取当前科目保存前的数据
|
|
|
|
|
dataListOld = MsCwAccitemsGlDAL.GetDataList(" and GID='" + headData.GID.ToString() + "'", Convert.ToString(Session["USERID"]));
|
|
|
|
|
|
|
|
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
|
|
|
headData.ModelUIStatus = "E";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isPost)
|
|
|
|
|
{
|
|
|
|
|
var modb = new ModelObjectDB();
|
|
|
|
|
DBResult result = modb.Save(headData);
|
|
|
|
|
if (result.Message.ToString().IndexOf("插入重复键") > -1)
|
|
|
|
|
{
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "重复,不允许保存!" };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string sError1 = "";
|
|
|
|
|
if (opstatus == "add")
|
|
|
|
|
{
|
|
|
|
|
#region 新建科目则,更新其父类科目不再是末级科目
|
|
|
|
|
string strSQL = "update cw_accitems_gl set DETAILED=0 where gid='" + headData.PACCGID.ToString() + "'";
|
|
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(strSQL);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 如果有父类科目,则替换此子科目的科目类型
|
|
|
|
|
if (headData.PACCGID.ToString() != "ZC" && headData.PACCGID.ToString() != "FZ" && headData.PACCGID.ToString() != "GT" && headData.PACCGID.ToString() != "QY" && headData.PACCGID.ToString() != "CB" && headData.PACCGID.ToString() != "SY")
|
|
|
|
|
{
|
|
|
|
|
var dataListP = MsCwAccitemsGlDAL.GetDataList(" and GID='" + headData.PACCGID.ToString() + "'", Convert.ToString(Session["USERID"]));
|
|
|
|
|
MsCwAccitemsGl headDataP = dataListP[0];
|
|
|
|
|
DBResult result3 = MsCwAccitemsGlDAL.updateZiKeMu(headData.PACCGID, headDataP.ISBANK, headDataP.ISSETTLEMENT, Convert.ToString(Session["USERID"]));
|
|
|
|
|
if (!result3.Success)
|
|
|
|
|
{
|
|
|
|
|
sError1 = headData.ACCNAME + " 此科目的科目类型更改失败!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#region 如果科目代码或名称变更,则替换数据库中所有涉及的数据
|
|
|
|
|
MsCwAccitemsGl headDataOld = dataListOld[0];
|
|
|
|
|
if (headData.ACCID != headDataOld.ACCID || headData.ACCNAME != headDataOld.ACCNAME)
|
|
|
|
|
{
|
|
|
|
|
DBResult result3 = MsCwAccitemsGlDAL.updateName(headData.ACCID, headDataOld.ACCID, headData.ACCNAME, headDataOld.ACCNAME, headData, Convert.ToString(Session["USERID"]));
|
|
|
|
|
if (!result3.Success)
|
|
|
|
|
{
|
|
|
|
|
sError1 = "凭证信息中更新科目代码或名称失败!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 如果科目类型变更,则替换此子科目的科目类型
|
|
|
|
|
if (headData.ISBANK != headDataOld.ISBANK || headData.ISSETTLEMENT != headDataOld.ISSETTLEMENT)
|
|
|
|
|
{
|
|
|
|
|
DBResult result3 = MsCwAccitemsGlDAL.updateZiKeMu(headData.GID, headData.ISBANK, headData.ISSETTLEMENT, Convert.ToString(Session["USERID"]));
|
|
|
|
|
if (!result3.Success)
|
|
|
|
|
{
|
|
|
|
|
sError1 = headData.ACCNAME + " 科目的子科目的科目类型更改失败!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 币别的处理
|
|
|
|
|
//判断币别是否启用
|
|
|
|
|
string sError = "";
|
|
|
|
|
DataSet dsFCYNO = null;
|
|
|
|
|
if (opstatus == "edit")
|
|
|
|
|
{
|
|
|
|
|
string strSQL = "SELECT FCYNO from VW_cw_vouchers_vouitems_gl where STARTGID='" + strCwSTARTGID + "' and ACCGID='" + headData.GID.ToString() + "' group by FCYNO";// and FCYNO<>'RMB'
|
|
|
|
|
dsFCYNO = T_ALL_DA.GetAllSQL(strSQL);
|
|
|
|
|
}
|
|
|
|
|
if (dsFCYNO != null)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < dsFCYNO.Tables[0].Rows.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (data.IndexOf(dsFCYNO.Tables[0].Rows[i]["FCYNO"].ToString()) < 0)
|
|
|
|
|
{
|
|
|
|
|
sError += headData.ACCID.ToString() + "-" + headData.ACCNAME.ToString() + "的" + dsFCYNO.Tables[0].Rows[i]["FCYNO"].ToString() + "已经使用不再修改!<br />";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (sError.Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
string strSQL = "delete from cw_accitems_currency where LINKGID='" + headData.GID.ToString() + "'";
|
|
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(strSQL);
|
|
|
|
|
//
|
|
|
|
|
#region 如果是外币
|
|
|
|
|
if (headData.ISFCY)
|
|
|
|
|
{
|
|
|
|
|
strSQL = "select * from code_currency";
|
|
|
|
|
DataSet ds = T_ALL_DA.GetAllSQL(strSQL);
|
|
|
|
|
if (ds != null)
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (data.IndexOf(ds.Tables[0].Rows[i]["CODENAME"].ToString()) > -1)
|
|
|
|
|
{
|
|
|
|
|
strSQL = "INSERT INTO cw_accitems_currency(GID,LINKGID,CURRENCY,CORPID,CREATEUSER,CREATETIME) VALUES(newid(),'" + headData.GID.ToString() + "','" + ds.Tables[0].Rows[i]["CODENAME"].ToString() + "','" + Convert.ToString(Session["COMPANYID"]) + "','" + Convert.ToString(Session["USERID"]) + "',getdate())";
|
|
|
|
|
bl = T_ALL_DA.GetExecuteSqlCommand(strSQL);
|
|
|
|
|
//
|
|
|
|
|
#region 插入总账表
|
|
|
|
|
strSQL = "select top 1 GID from cw_genleg_accitems where [STARTGID]='" + strCwSTARTGID + "' and [YEAR]='" + sYEAR + "' and [MONTH]='" + sMONTH + "' and [LINKGID]='" + headData.GID.ToString() + "' and [DEPTACC]='' and [EMPLACC]='' and [CORPACC]='' and [ITEMACC]='' and [CURRENCY]='" + ds.Tables[0].Rows[i]["CODENAME"].ToString() + "'";// and [CORPID]='" + Convert.ToString(Session["COMPANYID"]) + "'
|
|
|
|
|
string sCgaGid = T_ALL_DA.GetStrSQL("GID", strSQL);
|
|
|
|
|
if (sCgaGid.Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
strSQL = "INSERT INTO [cw_genleg_accitems]([GID],[YEAR],[MONTH],[LINKGID],[DEPTACC],[EMPLACC],[CORPACC],[ITEMACC],[CURRENCY],[AMTYEARDR],[AMTYEARCR],[AMTYEARBLC],[AMTDR],[AMTCR],[AMTBLC],[AMTLASTDR],[AMTLASTCR],[AMTLASTBLC],[FCYYEARDR],[FCYYEARCR],[FCYYEARBLC],[FCYDR],[FCYCR],[FCYBLC],[FCYLASTDR],[FCYLASTCR],[FCYLASTBLC],[QTYYEARDR],[QTYYEARCR],[QTYYEARBLC],[QTYDR],[QTYCR],[QTYBLC],[QTYLASTDR],[QTYLASTCR],[QTYLASTBLC],[PFADR],[PFACR],[CORPID],[ISDELETE],[DELETEUSER],[DELETETIME],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],[ISENABLE],[STARTGID],[ACCDATE],[IsInitialEntry])"
|
|
|
|
|
+ " VALUES (newid(),'" + sYEAR + "','" + sMONTH + "','" + headData.GID.ToString() + "','','','','','" + ds.Tables[0].Rows[i]["CODENAME"].ToString() + "',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,'" + Convert.ToString(Session["COMPANYID"]) + "',0,'" + Convert.ToString(Session["USERID"]) + "',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "',GETDATE()," + icount + ",'" + strCwSTARTGID + "','" + strCwACCDATE + "',0)";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSQL = "update [cw_genleg_accitems] set [CORPID]='" + Convert.ToString(Session["COMPANYID"]) + "',[MODIFIEDUSER]='" + Convert.ToString(Session["USERID"]) + "',[MODIFIEDTIME]=GETDATE() where GID='" + sCgaGid + "'";
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
bl = T_ALL_DA.GetExecuteSqlCommand(strSQL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#region 插入总账表
|
|
|
|
|
strSQL = "select top 1 GID from cw_genleg_accitems where [STARTGID]='" + strCwSTARTGID + "' and [YEAR]='" + sYEAR + "' and [MONTH]='" + sMONTH + "' and [LINKGID]='" + headData.GID.ToString() + "' and [DEPTACC]='' and [EMPLACC]='' and [CORPACC]='' and [ITEMACC]='' and [CURRENCY]='RMB'";// and [CORPID]='" + Convert.ToString(Session["COMPANYID"]) + "'
|
|
|
|
|
string sCgaGid = T_ALL_DA.GetStrSQL("GID", strSQL);
|
|
|
|
|
if (sCgaGid.Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
strSQL = "INSERT INTO [cw_genleg_accitems]([GID],[YEAR],[MONTH],[LINKGID],[DEPTACC],[EMPLACC],[CORPACC],[ITEMACC],[CURRENCY],[AMTYEARDR],[AMTYEARCR],[AMTYEARBLC],[AMTDR],[AMTCR],[AMTBLC],[AMTLASTDR],[AMTLASTCR],[AMTLASTBLC],[FCYYEARDR],[FCYYEARCR],[FCYYEARBLC],[FCYDR],[FCYCR],[FCYBLC],[FCYLASTDR],[FCYLASTCR],[FCYLASTBLC],[QTYYEARDR],[QTYYEARCR],[QTYYEARBLC],[QTYDR],[QTYCR],[QTYBLC],[QTYLASTDR],[QTYLASTCR],[QTYLASTBLC],[PFADR],[PFACR],[CORPID],[ISDELETE],[DELETEUSER],[DELETETIME],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],[ISENABLE],[STARTGID],[ACCDATE],[IsInitialEntry])"
|
|
|
|
|
+ " VALUES (newid(),'" + sYEAR + "','" + sMONTH + "','" + headData.GID.ToString() + "','','','','','RMB',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,'" + Convert.ToString(Session["COMPANYID"]) + "',0,'" + Convert.ToString(Session["USERID"]) + "','" + DateTime.Now + "','" + Convert.ToString(Session["USERID"]) + "','" + DateTime.Now + "','" + Convert.ToString(Session["USERID"]) + "','" + DateTime.Now + "'," + icount + ",'" + strCwSTARTGID + "','" + strCwACCDATE + "',0)";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSQL = "update [cw_genleg_accitems] set [CORPID]='" + Convert.ToString(Session["COMPANYID"]) + "',[MODIFIEDUSER]='" + Convert.ToString(Session["USERID"]) + "',[MODIFIEDTIME]=GETDATE() where GID='" + sCgaGid + "'";
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
bl = T_ALL_DA.GetExecuteSqlCommand(strSQL);
|
|
|
|
|
}
|
|
|
|
|
strSQL = "update [cw_genleg_accitems] set [STARTGID]='" + strCwSTARTGID + "' where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and (STARTGID='' or STARTGID is null)";
|
|
|
|
|
bl = T_ALL_DA.GetExecuteSqlCommand(strSQL);
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
sError = sError1 + sError;
|
|
|
|
|
if (sError.Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "!" + sError;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
//
|
|
|
|
|
string sGID = headData.GID;
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsCwAccitemsGlDAL.GetData("GID='" + sGID + "'", Convert.ToString(Session["USERID"])) };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "重复,不允许保存!" };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 末级科目新增第一个下级科目
|
|
|
|
|
public ContentResult SaveDetailed(string data, string PGID, string PACCID, string PACCNAME)
|
|
|
|
|
{
|
|
|
|
|
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 headData = JsonConvert.Deserialize<MsCwAccitemsGl>(data);
|
|
|
|
|
headData.GID = Guid.NewGuid().ToString().Trim();
|
|
|
|
|
DBResult result = MsCwAccitemsGlDAL.SaveDetailed(headData, PGID, PACCID, PACCNAME, Convert.ToString(Session["USERID"]));
|
|
|
|
|
string GID = headData.GID.ToString().Trim();
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = result.Success,
|
|
|
|
|
Message = result.Message,
|
|
|
|
|
Data = MsCwAccitemsGlDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"]))
|
|
|
|
|
};
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 删除
|
|
|
|
|
public ContentResult Delete(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 modb = new ModelObjectDB();
|
|
|
|
|
var head = JsonConvert.Deserialize<MsCwAccitemsGl>(data);
|
|
|
|
|
string PACCGID = head.PACCGID.ToString();
|
|
|
|
|
string sGID = head.GID.ToString();
|
|
|
|
|
DBResult result = modb.Delete(head);
|
|
|
|
|
if (result.Success==true)
|
|
|
|
|
{
|
|
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
|
string strSQL = "select count(*) as hj from cw_accitems_gl where PACCGID='" + PACCGID + "'";
|
|
|
|
|
string ls = T_ALL_DA.GetStrSQL("hj", strSQL);
|
|
|
|
|
if (ls == "0")
|
|
|
|
|
{
|
|
|
|
|
strSQL = "update cw_accitems_gl set DETAILED=1 where GID='" + PACCGID + "'";
|
|
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(strSQL);
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
strSQL = "delete from cw_accitems_currency where LINKGID='" + sGID + "'";
|
|
|
|
|
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(strSQL);
|
|
|
|
|
//
|
|
|
|
|
strSQL = "delete from cw_genleg_accitems where LINKGID='" + sGID + "'";
|
|
|
|
|
bl2 = T_ALL_DA.GetExecuteSqlCommand(strSQL);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 复制上年科目(暂时废弃,迁移到账套启用模块的“启用”功能中)
|
|
|
|
|
public ContentResult onCopy()
|
|
|
|
|
{
|
|
|
|
|
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 = MsCwAccitemsGlDAL.onCopy(Convert.ToString(Session["COMPANYID"]).Trim(), Convert.ToString(Session["USERID"]).Trim());
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//判断是否有往年数据
|
|
|
|
|
public ContentResult isShowCopy(string strUserID)
|
|
|
|
|
{
|
|
|
|
|
string strCwACCDATE = BasicDataRefDAL.GetCwACCDATE(strUserID);
|
|
|
|
|
DBResult result = MsCwAccitemsGlDAL.isShowCopy(strCwACCDATE, Convert.ToString(Session["USERID"]).Trim());
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Message };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 科目编码生成
|
|
|
|
|
public ContentResult GetACCID(string PGID, string PACCID, string OpType)
|
|
|
|
|
{
|
|
|
|
|
MsCwAccitemsGl head = MsCwAccitemsGlDAL.GetACCID(PGID, PACCID, OpType, Convert.ToString(Session["USERID"]).Trim());
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 科目是否已经使用
|
|
|
|
|
public ContentResult GetIsDisable(string sACCID)
|
|
|
|
|
{
|
|
|
|
|
var strList = MsCwAccitemsGlDAL.GetIsDisable(sACCID, Convert.ToString(Session["USERID"]).Trim());
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "操作成功!", data = strList });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|