| | |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | | using System.IO; |
| | | using System.Web; |
| | | using System.Web.Http; |
| | | using System.Windows.Forms; |
| | | using WebAPI.Models; |
| | | using WebAPI.Controllers.SCGL.æ¥è®¡å管ç; |
| | | using System.Text.RegularExpressions; |
| | | |
| | | namespace WebAPI.Controllers.项ç®ç®¡ç.å·¥ä½ä»»å¡ |
| | | namespace WebAPI.Controllers.å·¥èµç®¡ç.æ£è¡¥é¡¹ç®è´¹ç¨å |
| | | { |
| | | public class Pay_DuSubsidyItemBillController : ApiController |
| | | { |
| | |
| | | private json objJsonResult = new json(); |
| | | public DataSet ds = new DataSet(); |
| | | public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill(); |
| | | DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); |
| | | DAL.ClsGy_Department_View oDept = new DAL.ClsGy_Department_View(); |
| | | DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View(); |
| | | DAL.ClsGy_ORGANIZATIONS_View oOrg = new DAL.ClsGy_ORGANIZATIONS_View(); |
| | | DAL.ClsGy_DuSubsidyItem_View oDuSItem = new DAL.ClsGy_DuSubsidyItem_View(); |
| | | public DAL.ClsPay_DuSubsidyItemBill BillOld = new DAL.ClsPay_DuSubsidyItemBill(); |
| | | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); |
| | | string user_LongShan = ""; |
| | | string HName_LongShan = ""; |
| | | |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region æ£è¡¥é¡¹ç®è´¹ç¨å æ°æ®å¯¼å
¥ |
| | | #region è·å导å
¥æä»¶çæ°æ® |
| | | [Route("Pay_DuSubsidyItemBill/Pay_DuSubsidyItemBillimport")] |
| | | [HttpPost] |
| | | public object Pay_DuSubsidyItemBillimport() |
| | | { |
| | | try |
| | | { |
| | | var WorkBookName = HttpContext.Current.Request["WorkBookName"]; |
| | | DBUtility.ClsPub.HOrgID = long.Parse(HttpContext.Current.Request["HOrgID"]); |
| | | //è·åæä»¶åç§° |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //è·åæä»¶ç©çè·¯å¾ |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //ä¿åæä»¶ |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 2, WorkBookName); |
| | | |
| | | //å 餿件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //å建临æ¶è¡¨ |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | DataTable tb3 = new DataTable("dt3"); |
| | | |
| | | //æ·»å åå |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //æ·»å æ°æ® |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | //è·å导å
¥æä»¶ååéåï¼ç¨äºåç«¯å¨æå |
| | | List<object> columnNameList = new List<object>(); |
| | | //æ·»å åå |
| | | foreach (DataColumn col in tb2.Columns) |
| | | { |
| | | Type dataType = col.DataType; |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; |
| | | columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//è·åå°DataColumnå对象çåå |
| | | } |
| | | |
| | | var error = ""; |
| | | |
| | | //æ¥è¯¢æ£è¡¥é¡¹ç®è´¹ç¨å没æçå |
| | | if (!tb2.Columns.Contains("æ¥æ")) |
| | | error += "æ²¡ææ¾å°ãæ¥æãçæ é¢,"; |
| | | if (!tb2.Columns.Contains("å¹´")) |
| | | error += "æ²¡ææ¾å°ãå¹´ãçæ é¢,"; |
| | | if (!tb2.Columns.Contains("æ")) |
| | | error += "æ²¡ææ¾å°ãæãçæ é¢,"; |
| | | if (!tb2.Columns.Contains("ç»ç»ä»£ç ")) |
| | | error += "æ²¡ææ¾å°ãç»ç»ä»£ç ãçæ é¢,"; |
| | | if (!tb2.Columns.Contains("ç»ç»")) |
| | | error += "æ²¡ææ¾å°ãç»ç»ãçæ é¢,"; |
| | | if (!tb2.Columns.Contains("é¨é¨ä»£ç ")) |
| | | error += "æ²¡ææ¾å°ãé¨é¨ä»£ç ãçæ é¢,"; |
| | | if (!tb2.Columns.Contains("é¨é¨åç§°")) |
| | | error += "æ²¡ææ¾å°ãé¨é¨åç§°ãçæ é¢,"; |
| | | if (!tb2.Columns.Contains("çç»ä»£ç ")) |
| | | error += "æ²¡ææ¾å°ãçç»ä»£ç ãçæ é¢,"; |
| | | if (!tb2.Columns.Contains("çç»")) |
| | | error += "æ²¡ææ¾å°ãçç»ãçæ é¢,"; |
| | | if (!tb2.Columns.Contains("è¡¨å¤´å¤æ³¨")) |
| | | error += "æ²¡ææ¾å°ãè¡¨å¤´å¤æ³¨ãçæ é¢,"; |
| | | if (!tb2.Columns.Contains("èå代ç ")) |
| | | error += "æ²¡ææ¾å°ãèå代ç ãçæ é¢,"; |
| | | if (!tb2.Columns.Contains("èååç§°")) |
| | | error += "æ²¡ææ¾å°ãèååç§°ãçæ é¢,"; |
| | | ////è·åææçæ£è¡¥é¡¹ç®ï¼å¤å®å¯¼å
¥æä»¶ä¸æªå
å«çæ£è¡¥é¡¹ç® |
| | | //DataSet ds_DuSubsidyItem; |
| | | //ds_DuSubsidyItem = oCN.RunProcReturn("select * from Gy_DuSubsidyItem", "Gy_DuSubsidyItem"); |
| | | //if (ds_DuSubsidyItem.Tables[0] != null) |
| | | //{ |
| | | // for (int i = 0; i < ds_DuSubsidyItem.Tables[0].Rows.Count; i++) |
| | | // { |
| | | // string DuSubsidyItem = ds_DuSubsidyItem.Tables[0].Rows[i]["HName"] == null ? "" : ds_DuSubsidyItem.Tables[0].Rows[i]["HName"].ToString(); |
| | | // if (!tb2.Columns.Contains(DuSubsidyItem)) |
| | | // error += "æ²¡ææ¾å°ã" + DuSubsidyItem + "ãçæ é¢,"; |
| | | // } |
| | | //} |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"Excel模æ¿åå¨é误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult = (json)Checkdata(tb2); |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | //å é¤ä¸´æ¶è¡¨æ°æ® |
| | | oCN.RunProc("delete from diyipi_Pay_DuSubsidyItemBill"); |
| | | |
| | | //临æ¶è¡¨æ·»å æ°æ® |
| | | for (int i = 0; i < tb2.Rows.Count; i++) |
| | | { |
| | | if (tb2.Rows[i]["èå代ç "].ToString() != "") |
| | | { |
| | | //æ ¹æ®ä»£ç è·åè¡¨æ°æ® |
| | | oOrg.GetInfoByNumber(tb2.Rows[i]["ç»ç»ä»£ç "].ToString()); |
| | | oDept.GetInfoByNumber(tb2.Rows[i]["é¨é¨ä»£ç "].ToString()); |
| | | oGroup.GetInfoByNumber(tb2.Rows[i]["çç»ä»£ç "].ToString()); |
| | | oEmp.GetInfoByNumber(tb2.Rows[i]["èå代ç "].ToString()); |
| | | |
| | | //è·åå
ç |
| | | Int64 HOrgID = oOrg.omodel.HItemID; |
| | | Int64 HDeptID = oDept.omodel.HItemID; |
| | | Int64 HGroupID = oGroup.omodel.HItemID; |
| | | Int64 HEmpID = oEmp.omodel.HItemID; |
| | | |
| | | for (int j = 12; j < tb2.Columns.Count - 1; j++) |
| | | { |
| | | oDuSItem.GetInfoByName(tb2.Columns[j].ColumnName); |
| | | Int64 HDuSID = oDuSItem.omodel.HItemID; |
| | | string HDuSNumber = oDuSItem.omodel.HNumber; |
| | | string HDuSName = oDuSItem.omodel.HName; |
| | | double HMoney = double.Parse(tb2.Rows[i][tb2.Columns[j].ColumnName].ToString()); |
| | | |
| | | string sql = "insert into diyipi_Pay_DuSubsidyItemBill(HDate,HYear,HPeriod,HOrgID,HOrgNumber,HOrgName,HDeptID,HDeptNumber,HDeptName" + |
| | | ",HGroupID,HGroupNumber,HGroupName,HRemarkMain,HEmpID,HEmpNumber,HEmpName,HDuSubsidyItemID,HDuSubsidyItemNumber,HDuSubsidyItemName,HMoney,HRemarkSub) " + |
| | | "values(" + |
| | | "'" + tb2.Rows[i]["æ¥æ"].ToString() + |
| | | "'," + int.Parse(tb2.Rows[i]["å¹´"].ToString()) + |
| | | "," + int.Parse(tb2.Rows[i]["æ"].ToString()) + |
| | | "," + HOrgID + |
| | | ",'" + tb2.Rows[i]["ç»ç»ä»£ç "].ToString() + |
| | | "','" + tb2.Rows[i]["ç»ç»"].ToString() + |
| | | "'," + HDeptID + |
| | | ",'" + tb2.Rows[i]["é¨é¨ä»£ç "].ToString() + |
| | | "','" + tb2.Rows[i]["é¨é¨åç§°"].ToString() + |
| | | "'," + HGroupID + |
| | | ",'" + tb2.Rows[i]["çç»ä»£ç "].ToString() + |
| | | "','" + tb2.Rows[i]["çç»"].ToString() + |
| | | "','" + tb2.Rows[i]["è¡¨å¤´å¤æ³¨"].ToString() + |
| | | "'," + HEmpID + |
| | | ",'" + tb2.Rows[i]["èå代ç "].ToString() + |
| | | "','" + tb2.Rows[i]["èååç§°"].ToString() + |
| | | "'," + HDuSID + |
| | | ",'" + HDuSNumber + |
| | | "','" + HDuSName + |
| | | "'," + HMoney + |
| | | ",'" + tb2.Rows[i]["表ä½å¤æ³¨"] + |
| | | "')"; |
| | | oCN.RunProc(sql); |
| | | } |
| | | } |
| | | |
| | | } |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region æ£æ¥å¯¼å
¥æä»¶çæ°æ® |
| | | private object Checkdata(DataTable dt) |
| | | { |
| | | bool b = false; |
| | | string sErrMsg = ""; |
| | | string sMsg = ""; |
| | | for (int i = 0; i <= dt.Rows.Count - 1; i++) |
| | | { |
| | | string HDeptNumber = ""; |
| | | string HGroupNumber = ""; |
| | | string HEmpNumber = ""; |
| | | double HMoney = 0; |
| | | |
| | | HDeptNumber = DBUtility.ClsPub.isStrNull(dt.Rows[i]["é¨é¨ä»£ç "].ToString()); |
| | | HGroupNumber = DBUtility.ClsPub.isStrNull(dt.Rows[i]["çç»ä»£ç "].ToString()); |
| | | HEmpNumber = DBUtility.ClsPub.isStrNull(dt.Rows[i]["èå代ç "].ToString()); |
| | | if (HEmpNumber != "") |
| | | { |
| | | int index = i + 1; //è®°å½å½åæ£éªæ°æ®ä½äºå¯¼å
¥æä»¶ç第å è¡ |
| | | |
| | | //å®¡æ ¸ä»£ç æ¯å¦åç |
| | | if (!DBUtility.ClsPub.AllowNumber(HDeptNumber)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "é¨é¨ä»£ç ä¸ä¸è½åºç°è¿ç»â.âå¹¶ä¸é¦ä½æ«ä½ä¸è½ä¸ºâ.âï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (!DBUtility.ClsPub.AllowNumber(HGroupNumber)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "çç»ä»£ç ä¸ä¸è½åºç°è¿ç»â.âå¹¶ä¸é¦ä½æ«ä½ä¸è½ä¸ºâ.âï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (!DBUtility.ClsPub.AllowNumber(HEmpNumber)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "èå代ç ä¸ä¸è½åºç°è¿ç»â.âå¹¶ä¸é¦ä½æ«ä½ä¸è½ä¸ºâ.âï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //å¾å°é¨é¨å
ç |
| | | if (!oDept.GetInfoByNumber(HDeptNumber)) |
| | | { |
| | | sMsg = "[" + HDeptNumber + "]é¨é¨ä¸åå¨"; |
| | | if (sErrMsg.Contains(sMsg) == false) |
| | | { |
| | | sErrMsg = sErrMsg + "[" + HDeptNumber + "]é¨é¨ä¸åå¨\r\n"; |
| | | } |
| | | b = true; |
| | | } |
| | | //å¾å°çç»å
ç |
| | | if (!oGroup.GetInfoByNumber(HGroupNumber)) |
| | | { |
| | | sMsg = "[" + HGroupNumber + "]çç»ä¸åå¨"; |
| | | if (sErrMsg.Contains(sMsg) == false) |
| | | { |
| | | sErrMsg = sErrMsg + "[" + HGroupNumber + "]çç»ä¸åå¨\r\n"; |
| | | } |
| | | b = true; |
| | | } |
| | | |
| | | //å¾å°èåå
ç |
| | | if (!oEmp.GetInfoByNumber(HEmpNumber)) |
| | | { |
| | | sMsg = "[" + HEmpNumber + "]èåä¸åå¨"; |
| | | if (sErrMsg.Contains(sMsg) == false) |
| | | { |
| | | sErrMsg = sErrMsg + "[" + HEmpNumber + "]èåä¸åå¨\r\n"; |
| | | } |
| | | b = true; |
| | | } |
| | | //æ£éªå¯¼å
¥æä»¶ä¸çæ£è¡¥é¡¹ç®æ¯å¦åå¨ã弿¯å¦åæ³ |
| | | for(int j=12; j < dt.Columns.Count-1; j++) |
| | | { |
| | | //æ£éªå¯¼å
¥æä»¶ä¸çæ£è¡¥é¡¹ç®æ¯å¦åå¨ |
| | | if (!oDuSItem.GetInfoByName(dt.Columns[j].ColumnName)) |
| | | { |
| | | sMsg = "[" + dt.Columns[j].ColumnName + "]æ£è¡¥é¡¹ç®ä¸åå¨"; |
| | | if (sErrMsg.Contains(sMsg) == false) |
| | | { |
| | | sErrMsg = sErrMsg + "[" + dt.Columns[j].ColumnName + "]æ£è¡¥é¡¹ç®ä¸åå¨\r\n"; |
| | | } |
| | | b = true; |
| | | } |
| | | //æ£éªå¯¼å
¥æä»¶ä¸çæ£è¡¥é¡¹ç®å¼æ¯å¦åæ³ |
| | | if ( !Regex.IsMatch( dt.Rows[i][dt.Columns[j].ColumnName].ToString(), @"^\d+(\.\d+)?$")) |
| | | { |
| | | sMsg = "[" + dt.Columns[j].ColumnName + "]æ°æ®æ ¼å¼é误ï¼è¯·è¾å
¥éè´æ°"; |
| | | if (sErrMsg.Contains(sMsg) == false) |
| | | { |
| | | sErrMsg = sErrMsg + "[" + dt.Columns[j].ColumnName + "]æ°æ®æ ¼å¼é误ï¼è¯·è¾å
¥éè´æ°\r\n"; |
| | | } |
| | | b = true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (b == true) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = sErrMsg; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = sErrMsg; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region æ£è¡¥é¡¹ç®è´¹ç¨å ä¿å导å
¥æ°æ® |
| | | [Route("Pay_DuSubsidyItemBill/Pay_DuSubsidyItemBillSaveImport")] |
| | | [HttpGet] |
| | | public object Pay_DuSubsidyItemBillSaveImport(string user) |
| | | { |
| | | try |
| | | { |
| | | //æ¥çæé |
| | | if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ æ°å¢æéï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //è·å临æ¶è¡¨æ°æ® |
| | | ds = oCN.RunProcReturn("select * from diyipi_Pay_DuSubsidyItemBill order by HDate desc,HYear desc,HPeriod desc,HOrgID desc,HDeptID desc,HGroupID desc,HRemarkMain desc,HEmpID desc", "diyipi_Pay_DuSubsidyItemBill"); |
| | | if (ds==null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿åå¤±è´¥ï¼æ°æ®æªå¯¼å
¥æåï¼è¯·éæ°å¯¼å
¥æ°æ®ï¼ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //ä¿åæ°æ® |
| | | oCN.BeginTran(); |
| | | DataTable dt = ds.Tables[0]; |
| | | Pay_DuSubsidyItemBillMain mainTable = new Pay_DuSubsidyItemBillMain(); |
| | | List<Pay_DuSubsidyItemBillSub> subTable = new List<Pay_DuSubsidyItemBillSub>(); |
| | | int HOrgID = 0; |
| | | int HYear = 0; |
| | | int HPeriod = 0; |
| | | string compareText = ""; |
| | | |
| | | for (int i = 0; i < dt.Rows.Count; i++) |
| | | { |
| | | string compareText1 = dt.Rows[i]["HDate"].ToString() + |
| | | "" + dt.Rows[i]["HYear"].ToString() + |
| | | "" + dt.Rows[i]["HPeriod"].ToString() + |
| | | "" + dt.Rows[i]["HOrgID"].ToString() + |
| | | "" + dt.Rows[i]["HDeptID"].ToString() + |
| | | "" + dt.Rows[i]["HGroupID"].ToString() + |
| | | "" + dt.Rows[i]["HRemarkMain"].ToString() + |
| | | "" + dt.Rows[i]["HEmpID"].ToString(); |
| | | if(compareText != compareText1) |
| | | { |
| | | if (subTable.Count>0) |
| | | { |
| | | objJsonResult = SaveImport_AddBillMain(mainTable, subTable, HOrgID, HYear, HPeriod, user); |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | mainTable = new Pay_DuSubsidyItemBillMain(); |
| | | subTable.Clear(); |
| | | } |
| | | compareText = compareText1; |
| | | mainTable.HDate = dt.Rows[i]["HDate"].ToString(); |
| | | mainTable.HDeptID = int.Parse(dt.Rows[i]["HDeptID"].ToString()); |
| | | mainTable.HGroupID = int.Parse(dt.Rows[i]["HGroupID"].ToString()); |
| | | mainTable.HRemark = dt.Rows[i]["HRemarkMain"].ToString(); |
| | | mainTable.HMaker = user; |
| | | mainTable.HMakerDate = DateTime.Now.ToString("yyyy-MM-dd"); |
| | | HOrgID = int.Parse(dt.Rows[i]["HOrgID"].ToString()); |
| | | HYear = int.Parse(dt.Rows[i]["HYear"].ToString()); |
| | | HPeriod = int.Parse(dt.Rows[i]["HPeriod"].ToString()); |
| | | } |
| | | |
| | | Pay_DuSubsidyItemBillSub oSub = new Pay_DuSubsidyItemBillSub(); |
| | | oSub.HEmpID = int.Parse(dt.Rows[i]["HEmpID"].ToString()); |
| | | oSub.HDuSubsidyItemID = int.Parse(dt.Rows[i]["HDuSubsidyItemID"].ToString()); |
| | | oSub.HQty = 0; |
| | | oSub.HPrice = 0; |
| | | oSub.HMoney = double.Parse(dt.Rows[i]["HMoney"].ToString()); |
| | | oSub.HRemark = dt.Rows[i]["HRemarkSub"].ToString(); |
| | | subTable.Add(oSub); |
| | | } |
| | | |
| | | //æ·»å æå䏿¬¡è®°å½ |
| | | if (subTable.Count > 0) |
| | | { |
| | | objJsonResult = SaveImport_AddBillMain(mainTable, subTable, HOrgID, HYear, HPeriod, user); |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | mainTable = new Pay_DuSubsidyItemBillMain(); |
| | | subTable.Clear(); |
| | | } |
| | | |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucessï¼"; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region æ·»å æ£è¡¥é¡¹ç®è´¹ç¨å 主表 |
| | | public json SaveImport_AddBillMain(Pay_DuSubsidyItemBillMain mainTable, List<Pay_DuSubsidyItemBillSub> subTable, int HOrgID, int Year, int Period, string user) |
| | | { |
| | | string HComputerName = SystemInformation.ComputerName; //设å¤åç§° |
| | | |
| | | try |
| | | { |
| | | List<Pay_DuSubsidyItemBillMain> mainList = new List<Pay_DuSubsidyItemBillMain>(); |
| | | mainList.Add(mainTable); |
| | | |
| | | |
| | | int HYear = Year; |
| | | int HPeriod = Period; |
| | | string HBillType = "2233"; |
| | | string HBillSubType = ""; |
| | | int HBillStatus = 1; |
| | | |
| | | int HAutoSaveFlag = 0; |
| | | |
| | | |
| | | Int64 HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | string HBillNo = DBUtility.ClsPub.CreateBillCode(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true); |
| | | string HDate = mainList[0].HDate; |
| | | string HInnerBillNo = ""; |
| | | int HGroupID = mainList[0].HGroupID; |
| | | int HDeptID = mainList[0].HDeptID; |
| | | string HExplanation = ""; |
| | | string HRemark = mainList[0].HRemark; |
| | | |
| | | |
| | | string HMaker = mainList[0].HMaker; |
| | | string HMakerDate = mainList[0].HMakerDate; |
| | | |
| | | ds = oCN.RunProcReturn("select * from Pay_DuSubsidyItemBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_DuSubsidyItemBillMain"); |
| | | |
| | | //ä¸»è¡¨æ·»å æ°æ® |
| | | string sql = "insert into Pay_DuSubsidyItemBillMain" + |
| | | "(HYear,HPeriod,HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate,HInnerBillNo,HGroupID,HDeptID,HExplanation,HAutoSaveFlag,HRemark,HMaker,HMakeDate) " + |
| | | "values(" + |
| | | "" + HYear + |
| | | "," + HPeriod + |
| | | ",'" + HBillType + |
| | | "','" + HBillSubType + |
| | | "'," + HBillStatus + |
| | | "," + HInterID + |
| | | ",'" + HBillNo + |
| | | "','" + HDate + |
| | | "','" + HInnerBillNo + |
| | | "'," + HGroupID + |
| | | "," + HDeptID + |
| | | ",'" + HExplanation + |
| | | "'," + HAutoSaveFlag + |
| | | ",'" + HRemark + |
| | | "','" + HMaker + |
| | | "','" + HMakerDate + |
| | | "')"; |
| | | |
| | | //主表 |
| | | oCN.RunProc(sql); |
| | | LogService.Write("ç¨æ·:" + user + ",æ¥æ:" + DateTime.Now + ",æ°å¢æ£è¡¥é¡¹ç®è´¹ç¨å:" + HBillNo); |
| | | oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "æ°å¢æ£è¡¥é¡¹ç®è´¹ç¨åï¼" + HBillNo + "','LMES-æ£è¡¥é¡¹ç®è´¹ç¨å模å','" + DBUtility.ClsPub.IPAddress + "','æ°å¢åæ®'", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | |
| | | //ä¿åå表 |
| | | objJsonResult = SaveImport_AddBillSub(subTable, HInterID,HBillNo); |
| | | |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #region æ·»å æ£è¡¥é¡¹ç®è´¹ç¨å å表 |
| | | public json SaveImport_AddBillSub(List<Pay_DuSubsidyItemBillSub> DetailColl, Int64 HInterID, string HBillNo) |
| | | { |
| | | int i = 0; //ä½ä¸ºå表å
ç |
| | | foreach (Pay_DuSubsidyItemBillSub oSub in DetailColl) |
| | | { |
| | | i++; //åä¸ä¸ªä¸»è¡¨ä¸çå表çå
ç èªå¢ |
| | | |
| | | int HEntryID = i; |
| | | |
| | | int HEmpID = oSub.HEmpID; |
| | | int HDuSubsidyItemID = oSub.HDuSubsidyItemID; |
| | | double HQty = oSub.HQty; |
| | | double HPrice = oSub.HPrice; |
| | | double HMoney = oSub.HMoney; |
| | | string HRemark = oSub.HRemark; |
| | | |
| | | string sql = "insert into Pay_DuSubsidyItemBillSub" + |
| | | "(HInterID,HEntryID,HEmpID,HDuSubsidyItemID,HQty,HPrice,HMoney,HRemark) " + |
| | | "values(" + |
| | | "" + HInterID + |
| | | "," + HEntryID + |
| | | "," + HEmpID + |
| | | "," + HDuSubsidyItemID + |
| | | "," + HQty + |
| | | "," + HPrice + |
| | | "," + HMoney + |
| | | ",'" + HRemark + |
| | | "')"; |
| | | |
| | | oCN.RunProc(sql); |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | #endregion |
| | | #endregion |
| | | } |
| | | } |