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.

804 lines
38 KiB
C#

12 months ago
 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using DSWeb.Areas.OA.DAL.Baoxiao2;
using DSWeb.Areas.OA.Models.Baoxiao;
using DSWeb.Areas.OA.Models.Jiekuan;
using DSWeb.Areas.OA.Models.Comm;
using DSWeb.TruckMng.Comm.Cookie;
using DSWeb.TruckMng.Helper;
using DSWeb.TruckMng.Helper.Repository;
using DSWeb.Areas.CommMng.DAL;
using HcUtility.Comm;
using HcUtility.Core;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Text;
using System.Data;
using DSWeb.Areas.Import.Models.CwVouitems;
using DSWeb.Areas.Import.Models.CwDesign;
using DSWeb.Areas.Import.DAL.CwVouchersDAL;
using DSWeb.Areas.Import.Models.CwVouchers;
using DSWeb.EntityDA;
using WebSqlHelper;
using DSWeb.Areas.Account.Models.MsCwVouchersGl3;
namespace DSWeb.Areas.OA.Controllers
{
[JsonRequestBehavior]
public class Baoxiao2Controller : Controller
{
//
// GET: /Import/XXH
public ActionResult Index()
{
return View();
}
//
// GET: /Import/XXH/Edit
public ActionResult Edit()
{
return View();
}
// GET: /Import/XXH
public ActionResult NewIndex()
{
return View();
}
//
// GET: /Import/XXH/Edit
public ActionResult NewEdit()
{
return View();
}
public ActionResult NewAuditIndex()
{
return View();
}
//
// GET/Import/XXH/GetDataList
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = BaoxiaoDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string handle, string condition)
{
Baoxiaomb head = null;
if (handle == "edit")
{
var list = BaoxiaoDAL.GetDataList(condition, Convert.ToString(Session["USERID"]));
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new Baoxiaomb();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetFeeList(string BXGID)
{
var dataList = BaoxiaoDAL.GetFeeList("BXGID='" + BXGID + "'");
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetPayList(string BXGID)
{
var dataList = BaoxiaoDAL.GetPayList(BXGID, Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetThisFee(string MBLNO)
{
var dataList = BaoxiaoDAL.GetAmountList(" C.BSNO=(select bsno from vw_settlement where mblno='" + MBLNO + "') and c.feetype=2 and c.feestatus=1 and (BXGID is null or BXGID='')");
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetBSNO(string COMPANYID)
{
var dataList = BaoxiaoDAL.GetBSNO(COMPANYID);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
/*
public ContentResult GetAllBSNO ( string COMPANYID )
{
var dataList = BaoxiaoDAL.GetAllBSNO(COMPANYID);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}*/
public ContentResult GetAllBSNO ( string condition )
{
var dataList = BaoxiaoDAL.GetAllBSNO( condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetTruckMBLNO ( string COMPANYID )
{
var dataList = BaoxiaoDAL.GetTruckMBLNO("");
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetTruckBSNO ( string MBLNO )
{
var dataList = BaoxiaoDAL.GetTruckBSNO(" where MBLNO='" + MBLNO + "'");
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetBaoXiao2Body ( string condition )
{
var dataList = BaoxiaoDAL.GetBaoXiao2Body(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult Save ( string opstatus, string data, string data2, string FeeBody, string FeeDelBody,
string Paybody, string PayDelbody)
{
var head = JsonConvert.Deserialize<Baoxiao2mb>(data.Replace("}", ",") + data2.Replace("{", ""));
var FeebodyList = JsonConvert.Deserialize<List<BaoXiao2Bodymb>>(FeeBody);
var FeeDelbodyList = JsonConvert.Deserialize<List<BaoXiao2Bodymb>>(FeeDelBody);
var PaybodyList = JsonConvert.Deserialize<List<BXPaymb>>(Paybody);
var PayDelbodyList = JsonConvert.Deserialize<List<BXPaymb>>(PayDelbody);
head.AMOUNT = "0";
if (opstatus == "add")
{
head.DbOperationType = DbOperationType.DbotIns;
head.ModelUIStatus = "I";
head.BXGID = PubSysDAL.GetBillNo("0401"); //获取管理费单号
//20131011 应客户要求,将合同号改为接单人手动填写的必填项目。不再自动生成合同号
//自动填写接单审单人id
head.CREATEUSER = CookieConfig.GetCookie_UserName(Request);
/*
if (FeebodyList!=null)
foreach (var Fee in FeebodyList)
{
if (Fee.GID == "")
{
Fee.GID = PubSysDAL.getGuid();
}
else {
Fee.BXGID = head.BXGID;
}
}*/
}
else if (opstatus == "edit")
{
/*
if (FeebodyList != null)
foreach (var Fee in FeebodyList)
{
if (Fee.GId == "")
{
Fee.GId = PubSysDAL.getGuid();
}
} */
head.DbOperationType = DbOperationType.DbotUpd;
head.ModelUIStatus = "E";
}
else
{
head.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectRepository();
DBResult result = modb.Save(head,
ModelObjectConvert<BaoXiao2Bodymb>.ToModelObjectList(FeebodyList),
ModelObjectConvert<BaoXiao2Bodymb>.ToModelObjectList(FeeDelbodyList),
ModelObjectConvert<BXPaymb>.ToModelObjectList(PaybodyList),
ModelObjectConvert<BXPaymb>.ToModelObjectList(PayDelbodyList)
);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = BaoxiaoDAL.GetData("BX.BXGID='" + head.BXGID + "'", Convert.ToString(Session["USERID"]))
};
//20151116 取消对中物储的挂帐逻辑
//p_op_gain(head.BXGID);
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Delete(string data,string USERID)
{
var head = JsonConvert.Deserialize<Baoxiaomb>(data);
var BXGID = head.BXGID;
var modb = new ModelObjectDB();
DBResult result = modb.Delete(head, USERID, true
, " delete from ch_fee where BXGID ='" + head.BXGID + "' and isnull(jkgid,'')='' "
, "update ch_fee set BXGID='',feestatus=0,settlement=0 where BXGID='" + head.BXGID + "'"
, "delete from OA_Baoxiao_Pay where BXGID='" + head.BXGID + "'"
);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
//var _count = 0;
//_count = BaoxiaoDAL.DELBXChFee(BXGID);
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveSTL ( string BXGID, string Paybody, string PayDelbody )
{
var PaybodyList = JsonConvert.Deserialize<List<BXPaymb>>(Paybody);
var PayDelbodyList = JsonConvert.Deserialize<List<BXPaymb>>(PayDelbody);
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm("BXGID", BXGID,
ModelObjectConvert<BXPaymb>.ToModelObjectList(PaybodyList),
ModelObjectConvert<BXPaymb>.ToModelObjectList(PayDelbodyList)
);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult AddJKFee ( string BXGID, string FeeList )
{
var _count = 0;
//var corpcode = CookieConfig.GetCookie_OrgCode(Request);
//var userid = CookieConfig.GetCookie_UserId(Request);
_count = BaoxiaoDAL.AddJKFee(BXGID,FeeList);
var _success = false;
if (_count > 0)
{
_success = true;
}
var json = JsonConvert.Serialize(new { Success = _success, Message = "查询成功", totalCount = _count });
return new ContentResult() { Content = json };
}
public ContentResult DelJKFee ( string FeeList )
{
var _count = 0;
//var corpcode = CookieConfig.GetCookie_OrgCode(Request);
//var userid = CookieConfig.GetCookie_UserId(Request);
_count = BaoxiaoDAL.DelJKFee(FeeList);
var _success = false;
if (_count > 0)
{
_success = true;
}
var json = JsonConvert.Serialize(new { Success = _success, Message = "查询成功", totalCount = _count });
return new ContentResult() { Content = json };
}
public ContentResult AddJKBill(string BXGID, string BillList)
{
var JieKuanbodyList = JsonConvert.Deserialize<List<Jiekuan2mb>>(BillList);
foreach (var JieKuanitems in JieKuanbodyList) {
var strSql = new StringBuilder();
strSql.Append(" Update ch_fee set bxgid='" + BXGID + "' where JKGID='"+ JieKuanitems.GID+ "' AND ISNULL(BXGID,'')='' ");
Database db = DatabaseFactory.CreateDatabase();
db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
}
var json = JsonConvert.Serialize(new { Success =true, Message = "查询成功"});
return new ContentResult() { Content = json };
}
public ContentResult CreateVoucher(string VoucherDate, string UsdExrate, string User,
string useRate, string feesql,string DEPTGID,string zhaiyao)
{
var modb = new ModelObjectDB();
DBResult result = CreateDCVoucher(VoucherDate, UsdExrate, User, useRate, feesql,DEPTGID,zhaiyao );
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public DBResult CreateDCVoucher(string VoucherDate, string UsdExrate, string User,
string useRate, string feesql,string DEPTGID,string zhaiyao)
{
var result = new DBResult();
result.Success = true;
var UserID = Convert.ToString(CookieConfig.GetCookie_UserId(Request));
Database db_t = DatabaseFactory.CreateDatabase();
string strCheckRow = " select USERNAME from [user] where gid= '" + UserID + "' ";
object statusObj = SqlHelper.ExecuteScalar(db_t.ConnectionString, CommandType.Text, strCheckRow, null);
var EnName = statusObj.ToString();
var VouitemsList = new List<CwVouitems>();
var VouOrdNo = Guid.NewGuid().ToString();
CwDesign CWDesign = CwVouchersDAL.GetCwDesign();
//var _DEPTNO = "";
if (CWDesign.AR == "" || CWDesign.AR == null)
{
result.Success = false;
result.Message = "请先设置帐套信息,才能生成凭证!";
}
else
{
decimal DebitAmt = Convert.ToDecimal(0.00);
decimal CreditAmt = Convert.ToDecimal(0.00);
int itemsno = 1;
CwVouchers Voucher = new CwVouchers();
Database db = DatabaseFactory.CreateDatabase();
//借方数据 成本 进项税 销项税
using (var conn = db.CreateConnection())
{
conn.Open();
var strSql = new StringBuilder();
if (useRate == "1")
{/* ");*/
strSql.Append(" select vs.mblno,_t2.bsno,_t2.CUSTOMERNAME,_t2.jf,_t2.REASON,_t2.FEENAME,_t2.kemu,_t2.CHEQUENUM,_t2.BlockName ");
strSql.Append(" ,(select value from info_client_company where CompanyID=(select top 1 companyid from vw_user where deptgid='" + DEPTGID + "') ");
strSql.Append(" and customergid=(select gid from info_client where SHORTNAME=_t2.CUSTOMERNAME and isstop=0) and fieldname='CWDM') CustomerDM");
strSql.Append(" ,case reason when '费用' then feename ");
if (DEPTGID == "959EA28A-F5BE-8126-2E9D-CAE6C5BAD033")
{//是天津分集装箱部
strSql.Append(" else '业务编号:'+ isnull(vs.CUSTNO,'')+'/'+feename end as ZHAIYAO, ");
}
else
{
strSql.Append(" else '提单号:'+ isnull(vs.mblno,'')+'/'+feename end as ZHAIYAO, ");
}
strSql.Append(" isnull(OP.PROJECTNO,0) PROJECTNO, ic.FARCODE, ");
strSql.Append(" (select deptno from sys_dept where GID='" + DEPTGID + "') deptno ");
strSql.Append(" FROM (select _t.bsno,_t.customername, jf,reason,feename, ");
strSql.Append(" case reason when '成本' then '520101'");//(select FINANCESOFTCODE from sys_dept where GID='"+DEPTGID+"') ");
strSql.Append(" when '垫付' then case '" + DEPTGID + "' when 'FCD03297-2B64-5B9E-C9D5-2D6B475AE932' then '12210602' else '12210601' end ");
strSql.Append(" when '押箱' then '12210501' when '费用' then dbo.getfeegroup(feename) ");
//退押箱 应该怎么处理邓羽20150326
strSql.Append(" when '税' then case '" + DEPTGID + "' when 'FCD03297-2B64-5B9E-C9D5-2D6B475AE932' then '2221010102' else '2221010101' end end as kemu ");
strSql.Append(" ,CHEQUENUM, case reason when '成本' then (select FINANCESOFTCODE from sys_dept where GID='" + DEPTGID + "')");
/*
strSql.Append(" case '" + DEPTGID + "' when 'FCD03297-2B64-5B9E-C9D5-2D6B475AE932' then '050301:中物储业务板块' ");
strSql.Append(" when '959EA28A-F5BE-8126-2E9D-CAE6C5BAD033' then '010201:中物储业务板块' ");
strSql.Append(" when '91FF3699-A1B0-29AD-A955-914612D5F609' then '010201:中物储业务板块' ");
strSql.Append(" when '9A09D3AC-F0E3-F4B2-57E0-57727D301A2C' then '010202:中物储业务板块' ");
strSql.Append(" when '9F615B3B-0E92-DBC4-0FFD-CAD2E03F3D77' then '010203:中物储业务板块' ");
strSql.Append(" else '' end ");*/
strSql.Append(" when '垫付' then '' when '押箱' then '' when '费用' then ");
strSql.Append(" case feename when '餐费' then '02:业务板块' when '业务招待费' then '02:业务板块' else '109:中储业务板块' end ");
strSql.Append(" end as BlockName ");
strSql.Append(" FROM (select bsno,customername,notaxamount jf,reason,feename,CHEQUENUM from ch_fee where bxgid IN "+ feesql );
strSql.Append(" and ISADVANCEDPAY=0 ");
strSql.Append(" union all select bsno,customername,amount jf,reason,feename,CHEQUENUM from ch_fee where bxgid IN " + feesql);
strSql.Append(" and ISADVANCEDPAY=1 ");
strSql.Append(" union all select bsno,customername,tax as jf,'税','进项税额',CHEQUENUM from ch_fee where bxgid IN " + feesql );
strSql.Append(" and ISADVANCEDPAY=0 ");
strSql.Append(" and tax<>0 )_t )_t2 ");
strSql.Append(" left join vw_settlement vs on vs.bsno=_t2.bsno ");
strSql.Append(" left join info_client ic on ic.shortname=_t2.customername and ic.isstop=0 ");
strSql.Append(" left join OA_ProjectInfo OP on OP.BLNO=vs.MBLNO order by kemu ");
}
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
//var Accitems = CwVouchersDAL.GetCwAccitems(Convert.ToString(reader["FEENAME"]));
var Accitems = CwVouchersDAL.GetCwAccitems(Convert.ToString(reader["kemu"]));
if (Accitems.ACCID == "" || Accitems.ACCID == null)
{
result.Success = false;
result.Message = "单号:" + Convert.ToString(reader["mblno"]) + " 没有对应的财务科目!";
}
//if ( Convert.ToString(reader["mblno"]))
CwVouitems data = new CwVouitems();
data.CORPID = Convert.ToString(reader["FARCODE"]);
data.CUSTOMERNAME = Convert.ToString(reader["CustomerDM"]);
data.BLNO = Convert.ToString(reader["CHEQUENUM"]);//此处改为放置支票号
var MBLNO = Convert.ToString(reader["MBLNO"]);
if (MBLNO == "外代IC卡充值")//充值
{
data.CUSTOMERNAME = "011200000057";
}
if (MBLNO == "外运IC卡充值")//充值
{
data.CUSTOMERNAME = "011200000060";
}
if (MBLNO == "太平洋IC卡充值")//充值
{
data.CUSTOMERNAME = "011200000021";
}
if (Convert.ToString(reader["CustomerDM"]) == ""
&& !(MBLNO == "外代IC卡充值" || MBLNO == "外运IC卡充值" || MBLNO == "太平洋IC卡充值")
&& (Convert.ToString(reader["Reason"]) != "费用"))
{
result.Success = false;
result.Message = "单号:" + Convert.ToString(reader["CUSTOMERNAME"]) + " 没有设置分公司财务代码!";
}
data.ACCID = Accitems.ACCID;
data.ACCNAME = Accitems.ACCNAME;//科目名称
data.ORDNO = VouOrdNo;
data.EXPLAN = Convert.ToString(reader["zhaiyao"]);//摘要
data.ITEMNO = itemsno;
data.ISSYS = true;
//if (Accitems.DC == "借")
//{
data.DC = "D";
//}
//else if (Accitems.DC == "贷")
//{
// data.DC = "C";
//}
data.AMTDR = Convert.ToDecimal(reader["jf"]);
data.AMTCR = Convert.ToDecimal(0.00);
data.FCYCR = Convert.ToDecimal(0.00);
data.FCYDR = Convert.ToDecimal(reader["jf"]);
data.FCYEXRATE = Convert.ToDecimal(1);
data.FCYNO = "RMB";
data.DEPTID = Convert.ToString(reader["DEPTNO"]);//部门编码
data.ITEMID = Convert.ToString(reader["PROJECTNO"]);//通过提单号查询出的项目编号
DebitAmt = DebitAmt + data.AMTDR;
if (data.AMTDR!=0) {
itemsno = itemsno + 1;
VouitemsList.Add(data);
}
var buztype = Convert.ToString(reader["reason"]);
var feename=Convert.ToString(reader["feename"]);
if (feename == "进项税额")
{
data.FIELD2 = Convert.ToString(reader["DEPTNO"]) + ":部门";//部门编码
data.FIELD1 = "03:税率";
}
else
{
switch (buztype)
{
case ("成本"):
if (data.ITEMID == "" || data.ITEMID=="0")
{
result.Success = false;
var mes="";
if (Convert.ToString(reader["mblno"]) == "") {
mes = "(空白编号)";
}
else mes = Convert.ToString(reader["mblno"]);
result.Message = "单号:" + mes + " 没有设置项目编号!";
}
data.FIELD1 = Convert.ToString(reader["DEPTNO"]) + ":部门";//部门编码
//data.FIELD2 = Convert.ToString(reader["CUSTOMERNAME"]) + ":客商";//客商
data.FIELD2 = data.ITEMID + ":业务编号";//业务编号
data.FIELD3 = Convert.ToString(reader["BlockName"]) + ":中物储业务板块";//业务板块
break;
case ("垫付"):
if (data.ITEMID == "" || data.ITEMID == "0")
{
result.Success = false;
var mes = "";
if (Convert.ToString(reader["mblno"]) == "")
{
mes = "(空白编号)";
}
else mes = Convert.ToString(reader["mblno"]);
result.Message = "单号:" + mes + " 没有设置项目编号!";
}
data.FIELD1 = Convert.ToString(reader["DEPTNO"]) + ":部门";//部门编码
data.FIELD2 = data.CUSTOMERNAME + ":客商";//客商
data.FIELD3 = data.ITEMID + ":业务编号";//业务编号
break;
case ("押箱"):
if (data.ITEMID == "" || data.ITEMID == "0")
{
result.Success = false;
var mes = "";
if (Convert.ToString(reader["mblno"]) == "")
{
mes = "(空白编号)";
}
else mes = Convert.ToString(reader["mblno"]);
result.Message = "单号:" + mes + " 没有设置项目编号!";
}
data.FIELD1 = Convert.ToString(reader["DEPTNO"]) + ":部门";//部门编码
data.FIELD2 = data.CUSTOMERNAME + ":客商";//客商
data.FIELD3 = data.ITEMID + ":业务编号";//业务编号
break;
case ("费用"):
data.FIELD1 = Convert.ToString(reader["DEPTNO"]) + ":部门";//部门编码
data.FIELD3 = Convert.ToString(reader["BlockName"]) + ":中物储业务板块";//业务编号
break;
default: break;
}
//case buztype when
}
}
reader.Close();
}
}
//贷方 数据来自 OA_baoxiao_pay
using (var conn = db.CreateConnection())
{
conn.Open();
var strSql = new StringBuilder();
if (useRate == "1")
{
strSql.Append(" select obp.*,sb.subjectcode,sb.bankname,sb.codename,sb.ACCOUNT,(select deptno from sys_dept where GID='" + DEPTGID + "') deptno from OA_baoxiao_pay obp ");
strSql.Append(" left join sys_bank sb on sb.FINANCESOFTCODE=obp.FINANCIALCODE ");
strSql.Append(" where bxgid IN " + feesql + " ");
}
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var Accitems = CwVouchersDAL.GetCwAccitems(Convert.ToString(reader["subjectcode"]));
var BANKNAME = Convert.ToString(reader["bankname"]);
var CODENAME = Convert.ToString(reader["FINANCIALCODE"]);//obp.FINANCIALCODE sb.codename
if (Accitems.ACCID == "" || Accitems.ACCID == null)
{
result.Success = false;
result.Message = "贷方:" + BANKNAME + " 没有对应的财务科目!";
}
CwVouitems data = new CwVouitems();
if (Accitems.ACCID=="12210501")//压箱费
{
data.FIELD1 = Convert.ToString(reader["deptno"]) +":部门";
data.FIELD2 = Convert.ToString(reader["ACCOUNT"])+":客商";
data.FIELD3 = Convert.ToString(reader["FINANCIALCODE"])+":业务编号";
}else
if (Accitems.ACCID=="112101")//汇票
{
//data.FIELD1 = _DEPTNO+":部门";
data.FIELD1 = Convert.ToString(reader["ACCOUNT"])+":客商";
//data.FIELD3 = Convert.ToString(reader["FINANCIALCODE"])+":业务编号";
}else
{
//data.FIELD1 = "";
data.FIELD1 = Convert.ToString(reader["FINANCIALCODE"]) + ":银行账户";//银行
data.CUSTOMERNAME = "";
}
//支付结算没有客户
data.ACCID = Accitems.ACCID;//银行的科目编号
data.ACCNAME = Accitems.ACCNAME;//科目名称
data.ORDNO = VouOrdNo;
data.BLNO = Convert.ToString(reader["TICKETNO"]);//票号
data.EXPLAN = zhaiyao;//摘要
data.ITEMNO = itemsno;
data.ISSYS = true;
//if (Accitems.DC == "借")
//{
//data.DC = "D";
//}
//else if (Accitems.DC == "贷")
//{
data.DC = "C";
//}
data.AMTDR = Convert.ToDecimal(0.00);
data.AMTCR = Convert.ToDecimal(reader["AMOUNT"]);
data.FCYCR = Convert.ToDecimal(reader["AMOUNT"]);
data.FCYDR = Convert.ToDecimal(0.00);
data.FCYEXRATE = Convert.ToDecimal(1);
data.FCYNO = "RMB";
data.DEPTID = Convert.ToString(reader["deptno"]);//部门编码
//data.ITEMID = Convert.ToInt32(reader["PROJECTNO"]);//用提单号填充项目编码
data.FSETTLCODE = Convert.ToString(reader["SETTLEMENTTYPE"]);
CreditAmt = CreditAmt + data.AMTCR;
itemsno = itemsno + 1;
VouitemsList.Add(data);
}
reader.Close();
}
}
//凭证主表信息
Voucher.ORDNO = VouOrdNo;
var voudate = Convert.ToDateTime(VoucherDate);
Voucher.ACCYEAR = voudate.ToString("yyyy");
Voucher.ACCMONTH = voudate.ToString("MM");
Voucher.PREPARED = EnName;//User;//制单人
Voucher.VOUDATE = voudate;//制单时间
Voucher.VKNO = CWDesign.TVW;
Voucher.AMTDR = DebitAmt;
Voucher.AMTCR = CreditAmt;
////
var sSQL = "SELECT top 1 * from cw_design";
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
DataSet dsCwDesign = T_ALL_DA.GetAllSQL(sSQL);
if (dsCwDesign == null)
{
result.Success = false;
result.Message = "请先设置帐套!";
}
////
Voucher.VOUNO = CwVouchersDAL.getVOUNO(dsCwDesign, Voucher.ACCYEAR, Voucher.ACCMONTH);
Voucher.VOUALLNO = Voucher.ACCYEAR + Voucher.ACCMONTH + Voucher.VOUNO;
Voucher.ATTACHS = CWDesign.AFFIXNO;
Voucher.FCY = "";
Voucher.QTY = "";//是否含有数量科目="";//varchar="";//(1)
Voucher.VOUPROP = "";//凭证属性="";//varchar="";//(1)
Voucher.CHECKED = "";//审核人="";//varchar="";//(10)
Voucher.ENTERED = "";//记账人="";//varchar="";//(10)
Voucher.ERRMSG = "";//错误信息="";//varchar="";//(6)
Voucher.ISDELETE = false;//是否废除="";//bit="";//Y
Voucher.DELETEUSER = "";//废除操作人="";//Varchar(36)="";//Y
var strSel = " AND BXGID in " + feesql;
if (result.Success)
{
result = CwVouchersDAL.InsertVoucher(Voucher, VouitemsList, "OA_Baoxiao", Voucher.VOUALLNO, strSel, User);
}
}
return result;
}
public static int p_op_gain(string bxgid)
{
Database db = DatabaseFactory.CreateDatabase();
var cmd = db.GetStoredProcCommand("p_op_gain_bybxgid");
db.AddInParameter(cmd, "@bxgid", DbType.String, bxgid);
db.ExecuteNonQuery(cmd);
return 0;
}
public int SetGZ(string BXGID)
{//设置挂账信息
//var _count = 0;
var strSql = new StringBuilder();
//foreach (var BX in BaoxiaoList)
//{
//var BXGID = BX.BXGID;
strSql.Append( " update ch_fee set feestatus=0 where ");
strSql.Append( " CHEQUENUM in( select TICKETNO from OA_Baoxiao_Pay where SETTLEMENTTYPE=4 and bxgid='" + BXGID + "') ");
strSql.Append( " and bxgid='" + BXGID + "' ");
strSql.Append( " update ch_fee set feestatus=9 where ");
strSql.Append( " CHEQUENUM in( select TICKETNO from OA_Baoxiao_Pay where SETTLEMENTTYPE<>4 and bxgid='" + BXGID + "') ");
strSql.Append( " and bxgid='" + BXGID + "' ");
//}
return BaoxiaoDAL.SetFee(strSql);
}
#region 生成总账凭证
public ContentResult GetCodeCurrencyList(string strGids)
{
var dataList = BaoxiaoDAL.GetCodeCurrencyList(strGids, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult onAddCwVouchers(string strGids, string dataDiv, string jsonBody)
{
var headData = JsonConvert.Deserialize<MsCwVouchersGl3>(dataDiv);
List<MsCwVouchersGl4> bodyList = new List<MsCwVouchersGl4>();
if (jsonBody != null)
{
bodyList = JsonConvert.Deserialize<List<MsCwVouchersGl4>>(jsonBody);
}
if (bodyList == null && headData.ISRATE == false)
{
headData.ISRATE = true;
}
//
DBResult result2 = BaoxiaoDAL.GetIsVoucher(strGids, Convert.ToString(Session["USERID"]));
if (!result2.Success)
{
var jsonRespose2 = new JsonResponse { Success = result2.Success, Message = result2.Message, Data = "" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
DBResult result = BaoxiaoDAL.onAddCwVouchers(strGids, headData, bodyList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
//
string sGids = "'" + strGids.Trim().Replace(",", "','") + "'";
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
string sVOUCHERNO = T_ALL_DA.GetStrSQL("VOUCHERNO", "select top 1 VOUCHERNO from ch_fee_settlement where gid in (" + sGids + ")");
//
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = sVOUCHERNO };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetIsVoucher(string strGids)
{
DBResult result = BaoxiaoDAL.GetIsVoucher(strGids, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = "" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
/// <summary>
/// 是否自动弹出结算总账凭证
/// </summary>
/// <returns></returns>
public ContentResult onIsSettlementsopen()
{
DBResult result = BaoxiaoDAL.onIsSettlementsopen(Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = "" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
//
}
}