//生成账单头表billhead private Billhead BillheadAdd(double?customerid, double?dropcustomervalue, double?dropLabvalue) { try { Hashtable ht = (Hashtable)ViewState["sqlWhere"]; IList <Billdetail> detailList = billdetailService.GetBilldetailStatisticsByOrdernum("PrepareOut", ht); Billhead billhead = new Billhead(); if (dropLab.SelectedValue == "-1") { billhead.Dictlabid = null; } else { billhead.Dictlabid = dropLabvalue; } if (dropcustomervalue == null) { billhead.Dictcustomerid = null; } else { billhead.Dictcustomerid = dropcustomervalue; } int sta = (int)ParamStatus.BillheadStatus.PrepareOut; billhead.Status = sta.ToString(); billhead.Remark = ""; billhead.Createdate = System.DateTime.Now; billhead.Billby = Userinfo.userId; billhead.Duedate = null; billhead.Receipno = ""; billhead.Dictcheckbillid = customerid; billhead.Customertype = chkSendOut.Checked == true ? "1" : "0"; billhead.Billtype = "团检账单"; billhead.Totalgrouprprice = detailList.Sum(c => c.Groupprice); billhead.Totalcontractprice = detailList.Sum(c => c.Contractprice); billhead.Totalfinalprice = detailList.Sum(c => c.Finalprice); billhead.Totalstandardprice = detailList.Sum(c => c.Standardprice); billhead.Billheadid = billdetailService.getSeqID("SEQ_BILLHEAD"); billhead.Invoiceno = billhead.Billheadid.ToString(); billhead.Begindate = DateTime.Parse(dtpStart.Text); billhead.Enddate = DateTime.Parse(dtpEnd.Text); return(billhead); } catch (Exception ex) { MessageBoxShow(ex.Message, MessageBoxIcon.Error); return(null); } }
//预出账 protected void btnPreInvoice_Click(object sender, EventArgs e) { if (gvList.Rows.Count <= 0) { return; } try { string flag = ViewState["flag"].ToString(); Hashtable ht = (Hashtable)ViewState["sqlWhere"]; double? _customerid = Convert.ToDouble(ht["customerid"]); double? _dictlabid = Convert.ToDouble(ht["dictlabid"]); //获得财务清单核对人编号 double?checkbillid = null; if (_customerid != null) { List <Dictcustomer> customerList = loginService.GetDictcustomer(); List <Dictcustomer> customer = (from a in customerList where a.Dictcustomerid == _customerid select a).ToList <Dictcustomer>(); checkbillid = customer.Count > 0 ? customer[0].Dictcheckbillid : null; } //生成账单头表billhead Billhead billhead = new Billhead(); billhead = BillheadAdd(checkbillid, _customerid, _dictlabid); if (billhead == null) { return; } //事物处理"预出账"操作 bool result = billdetailService.BillPrepareOutOperation(billhead, ht, flag); BindData(); BindDataCount(); } catch (Exception ex) { MessageBoxShow(ex.Message, MessageBoxIcon.Error); } }
/// <summary> /// 事物处理个人收费"调价" /// </summary> /// <returns></returns> public bool BillIndividualUpdatePrice(IList <Ordergrouptest> oldList, IList <Ordergrouptest> newList, double?customerid, string ordernum, double dictlabid, string remark) { UserInfo userInfo = GetUserInfo(); try { //获得财务清单核对人 LoginService loginService = new LoginService(); List <Dictcustomer> customerList = loginService.GetDictcustomer(); int customercode = (int)ParamStatus.PersonalCustomerID.SingleCustomerCode; List <Dictcustomer> customer = (from a in customerList where a.Customercode == customercode.ToString() select a).ToList(); SortedList SQLlist = new SortedList(new MySort()); double? d = 0; //生成账单头表数据 Billhead head = new Billhead(); head.Dictlabid = dictlabid; int sta = (int)ParamStatus.BillheadStatus.PrepareOut; head.Status = sta.ToString(); head.Remark = remark; head.Createdate = System.DateTime.Now; head.Billby = userInfo.userId; head.Duedate = System.DateTime.Now; head.Receipno = ""; head.Dictcustomerid = customerid; head.Dictcheckbillid = customer.Count > 0 ? customer[0].Dictcheckbillid : null; head.Customertype = "0"; head.Billtype = "个检账单"; head.Totalcontractprice = newList.Sum(c => c.Contractprice); head.Totalfinalprice = newList.Sum(c => c.Finalprice); head.Totalstandardprice = newList.Sum(c => c.Standardprice); head.Totalgrouprprice = newList.Sum(c => c.Groupprice); head.Billheadid = this.getSeqID("SEQ_BILLHEAD"); head.Invoiceno = head.Billheadid.Value.ToString(); head.Begindate = DateTime.Now; head.Enddate = DateTime.Now; SQLlist.Add(new Hashtable() { { "INSERT", "Bill.InsertBillhead" } }, head); //循环生成账单明细信息 foreach (Ordergrouptest test in newList) { Billdetail detail = new Billdetail(); detail = SetBillDetail(head.Billheadid, ordernum, test, remark); detail.Billdetailid = this.getSeqID("SEQ_BILLDETAIL"); SQLlist.Add(new Hashtable() { { "INSERT", "Bill.InsertBilldetail" } }, detail); //更新ordergrouptest表实收价格 Hashtable htgrouptest = new Hashtable(); htgrouptest["flag"] = "nosendout"; htgrouptest["ordernum"] = ordernum; htgrouptest["dicttestitemid"] = test.Dicttestitemid; htgrouptest["finalprice"] = test.Finalprice; SQLlist.Add(new Hashtable() { { "UPDATE", "Order.UpdateOrdergrouptestFinalPrice" } }, htgrouptest); } bool result = this.ExecuteSqlTran(SQLlist); if (result) { //修改价钱日志记录 for (int i = 0; i < oldList.Count; i++) { if (!oldList[i].Finalprice.Equals(newList[i].Finalprice)) { UpdateBilldetailFinalpriceLog(oldList[i], newList[i], ordernum); } } //已付款日志记录 AddOperationLog(ordernum, "", "财务管理", "已收费", "节点信息", ""); } return(result); } catch (Exception ex) { return(false); throw new Exception(ex.Message); } }
/// <summary> /// 事物处理"预出账"操作 /// </summary> /// <returns></returns> public bool BillPrepareOutOperation(Billhead billhead, Hashtable ht, string flag) { try { BilldetailService service = new BilldetailService(); IList <Billdetail> detailList = service.SelectBilldetailList(ht); SortedList SQLlist = new SortedList(new MySort()); billhead.Billheadid = this.getSeqID("SEQ_BILLHEAD"); billhead.Invoiceno = billhead.Billheadid.ToString(); SQLlist.Add(new Hashtable() { { "INSERT", "Bill.InsertBillhead" } }, billhead); foreach (Billdetail detail in detailList) { //更新BILLDETAIL 表 Hashtable htdetail = new Hashtable(); htdetail["Billdetailids"] = detail.Billdetailid; htdetail["Billheadid"] = billhead.Billheadid; SQLlist.Add(new Hashtable() { { "UPDATE", "Bill.UpdateBilldetailHeadId" } }, htdetail); //更新ordergrouptest表 Hashtable htgrouptest = new Hashtable(); htgrouptest["flag"] = flag; htgrouptest["billdetailid"] = detail.Billdetailid; htgrouptest["ordernum"] = detail.Ordernum; htgrouptest["dicttestitemid"] = detail.Dicttestitemid; SQLlist.Add(new Hashtable() { { "UPDATE", "Order.UpdateOrdergrouptestPrice" } }, htgrouptest); } bool result = this.ExecuteSqlTran(SQLlist); if (result) { IEnumerator <Billdetail> ordernumList = (from a in detailList group a by new { a.Ordernum } into g select new Billdetail { Ordernum = g.Key.Ordernum }).ToList().GetEnumerator(); //预出账日志 while (ordernumList.MoveNext()) { this.AddOperationLog(ordernumList.Current.Ordernum, "", "财务管理", "预出账", "节点信息", ""); } } return(result); } catch (Exception ex) { return(false); throw new Exception(ex.Message); } }