protected void bt_Save_Click(object sender, EventArgs e) { FNA_FeeWriteOffBLL _bll = new FNA_FeeWriteOffBLL((int)ViewState["ID"]); FNA_FeeWriteOffDetail m = new FNA_FeeWriteOffDetail(); if ((int)ViewState["DetailID"] > 0) { m = _bll.GetDetailModel((int)ViewState["DetailID"]); m.ApplyCost = decimal.Parse(tbx_Taxes.Text.Trim()); m.WriteOffCost = m.ApplyCost; m.Remark = tbx_Remark.Text.Trim(); _bll.UpdateDetail(m); } else { m.ID = 0; m.ApplyDetailID = 0; m.Client = _bll.Model.InsteadPayClient; m.BeginMonth = _bll.Model.AccountMonth; m.EndMonth = _bll.Model.AccountMonth; m.AccountTitle = 129; m.ApplyCost = decimal.Parse(tbx_Taxes.Text.Trim()); m.WriteOffCost = m.ApplyCost; m.Remark = tbx_Remark.Text.Trim(); _bll.AddDetail(m); } Session["SuccessFlag"] = true; MessageBox.ShowAndClose(this, "税金调整成功。"); }
private void BindGrid() { ListTable <FNA_FeeWriteOffDetail> _details; if (ViewState["Details"] != null) { _details = ViewState["Details"] as ListTable <FNA_FeeWriteOffDetail>; } else { _details = new ListTable <FNA_FeeWriteOffDetail>(new FNA_FeeWriteOffBLL((int)ViewState["ID"]).Items, "ID"); } if (_details.GetListItem().Count(p => p.AccountTitle == 82) > 0) { ViewState["FLPurchase"] = FNA_FeeWriteOffBLL.GetPurchaseVolume((int)ViewState["ID"]); } gv_List.BindGrid <FNA_FeeWriteOffDetail>(_details.GetListItem().OrderBy(p => p.Client).ThenBy(p => p.AccountTitle).ThenBy(p => p.BeginMonth).ToList()); //求费用核消金额合计 decimal _totalcost = 0; foreach (FNA_FeeWriteOffDetail _detail in _details.GetListItem()) { _totalcost += _detail.WriteOffCost + _detail.AdjustCost; } lb_TotalCost.Text = _totalcost.ToString("0.###"); if (bt_EditWriteOffDetail.Visible || bt_AddTitleNoApply.Visible) { Session["FeeWriteOffDetails"] = ViewState["Details"]; //放入Session中,允许编辑明细 } }
protected void bt_Save_Click(object sender, EventArgs e) { if ((int)ViewState["DetailID"] != 0) { FNA_FeeWriteOffDetail _modeldetail = new FNA_FeeWriteOffBLL().GetDetailModel((int)ViewState["DetailID"]); FNA_FeeWriteOffBLL _bll = new FNA_FeeWriteOffBLL(_modeldetail.WriteOffID); pn_Detail.GetData(_modeldetail); if (_modeldetail["InvoiceClassify"] == "1" && _modeldetail["VATInvoiceNO"] == "") { MessageBox.Show(this, "请录入增值税发票号码!"); return; } if (_modeldetail["InvoiceClassify"] == "1" && _modeldetail["VATInvoiceNO"] != "" && FNA_FeeWriteOffBLL.VerifyNO(_modeldetail.ID, 1, _modeldetail["VATInvoiceNO"].Trim()) > 0) { MessageBox.Show(this, "增值税发票号码重复!"); return; } if (_modeldetail["AcceptanceNO"] != "" && FNA_FeeWriteOffBLL.VerifyNO(_modeldetail.ID, 2, _modeldetail["VATInvoiceNO"].Trim()) > 0) { MessageBox.Show(this, "验收凭证号码重复!"); return; } _bll.UpdateDetail(_modeldetail); Session["POP_AddFeeWriteOffAttachment"] = true; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "message", "<script language='javascript'>window.close();</script>", false); } }
private void BindGrid() { lbl_message.Text = "费用报销审批汇总表"; int id = (int)ViewState["ID"]; FNA_FeeWriteOffBLL bll = new FNA_FeeWriteOffBLL(id); ViewState["Details"] = bll.Items.OrderBy(p => p.Client).ThenBy(p => p.AccountTitle).ThenBy(p => p.BeginMonth).ToList(); FNA_FeeWriteOff writeoff = bll.Model; if (writeoff == null) { Response.Redirect("FeeWriteOffList.aspx"); } BindGridPrint(); string type = ""; if (writeoff["InvoiceClassAB"] != "") { type = DictionaryBLL.GetDicCollections("FNA_InvoiceClassAB")[writeoff["InvoiceClassAB"]].Name; } // type = DictionaryBLL.Dictionary_Data_GetAlllList("TableName='FNA_InvoiceClassAB' AND Code='" + writeoff["InvoiceClassAB"] + "'")[0].Name; if (type == "") { type = "抵款"; } span_sheetcode.InnerText = writeoff.SheetCode; span_accountmonth.InnerText = new AC_AccountMonthBLL(writeoff.AccountMonth).Model.Name; if (bll.Model["InsteadPayStaff"] != "" && bll.Model["InsteadPayStaff"] != "0") { p_ddtype.InnerText = "员工"; span_client.InnerText = new Org_StaffBLL(int.Parse(bll.Model["InsteadPayStaff"])).Model.RealName; } else { span_client.InnerText = new CM_ClientBLL(writeoff.InsteadPayClient).Model.FullName; } int city5 = TreeTableBLL.GetSuperIDByLevel("MCS_SYS.dbo.Addr_OrganizeCity", writeoff.OrganizeCity, 5); span_orgnizecity.InnerText = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", "ID", "Name", "SuperID", 1, city5 > 0 ? city5 : writeoff.OrganizeCity); span_type.InnerText = type; span1.InnerText = span2.InnerText = "1"; //求费用核消金额合计 decimal _totalcost = 0; foreach (FNA_FeeWriteOffDetail _detail in bll.Items) { _totalcost += _detail.WriteOffCost + _detail.AdjustCost; } lab_SubTotalCostCN.Text = MCSFramework.Common.Rmb.CmycurD(_totalcost.ToString()); lab_SubTotalCost.Text = _totalcost.ToString("#,##0.00"); lab_SubTotalCost.Text = lab_SubTotalCost.Text; lab_SubTotalCost.Text = lab_SubTotalCost.Text; }
protected void gv_ListDetail_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int id = (int)gv_ListDetail.DataKeys[e.Row.RowIndex][0]; UC_GridView gv_Detail = (UC_GridView)e.Row.FindControl("gv_Detail"); if (gv_Detail != null) { IList <FNA_FeeWriteOffDetail> lists = new FNA_FeeWriteOffBLL(id).Items; //费用类型 int accounttile = 0; int.TryParse(tr_AccountTitle.SelectValue, out accounttile); if (ddl_FeeType.SelectedValue != "0" && !(accounttile > 1)) { IList <AC_AccountTitleInFeeType> titles = AC_AccountTitleInFeeTypeBLL.GetModelList("FeeType=" + ddl_FeeType.SelectedValue); int[] ids = new int[titles.Count]; for (int i = 0; i < titles.Count; i++) { ids[i] = titles[i].AccountTitle; } lists = lists.Where(p => ids.Contains(p.AccountTitle)).ToList(); } //费用科目 if (accounttile > 1) { DataTable dt = TreeTableBLL.GetAllChildByNodes("MCS_PUB.dbo.AC_AccountTitle", "ID", "SuperID", accounttile.ToString()); int[] ids = new int[dt.Rows.Count + 1]; for (int i = 0; i < dt.Rows.Count; i++) { ids[i] = (int)dt.Rows[i]["ID"]; } ids[ids.Length - 1] = accounttile; lists = lists.Where(p => ids.Contains(p.AccountTitle)).ToList(); } //核销金额判断 decimal _cost = 0; decimal.TryParse(tbx_WriteOffCost.Text, out _cost); if (_cost != 0) { if (ddl_WriteOffCostOP.SelectedValue == ">") { lists = lists.Where(p => p.WriteOffCost + p.AdjustCost > _cost).ToList(); } else if (ddl_WriteOffCostOP.SelectedValue == "<") { lists = lists.Where(p => p.WriteOffCost + p.AdjustCost < _cost).ToList(); } } gv_Detail.BindGrid(lists); } } }
private void BindGridPrint() { IList <FNA_FeeWriteOffDetail> list = (IList <FNA_FeeWriteOffDetail>)ViewState["Details"]; if (list.Count(p => p.AccountTitle == 82) > 0) { ViewState["FLPurchase"] = FNA_FeeWriteOffBLL.GetPurchaseVolume((int)ViewState["ID"]); gv_ListDetail.Columns[9].Visible = true; } gv_ListDetail.BindGrid <FNA_FeeWriteOffDetail>(list.OrderBy(p => p.Client).ThenBy(p => p.AccountTitle).ThenBy(p => p.BeginMonth).ToList()); }
private void UpdateDetail(FNA_FeeWriteOffBLL bll, int AccountTitle, Decimal Cost, int flag, DateTime minbegindate, DateTime maxenddate) { if (Cost == 0) { return; } FNA_FeeWriteOffDetail d = bll.Items.FirstOrDefault(p => p.AccountTitle == AccountTitle); if (d != null) { if (flag == 1) { d.WriteOffCost += Cost; if (d.BeginDate > minbegindate) { d.BeginDate = minbegindate; } if (d.EndDate < maxenddate) { d.EndDate = maxenddate; } } else { d.WriteOffCost -= Cost; } if (d.WriteOffCost == 0) { bll.DeleteDetail(d.ID); } else { bll.UpdateDetail(d); } } else { if (flag == 1) { d = new FNA_FeeWriteOffDetail(); d.AccountTitle = AccountTitle; d.ApplyCost = 0; d.WriteOffCost = Cost; d.BeginDate = minbegindate; d.EndDate = maxenddate; d.BeginMonth = bll.Model.AccountMonth; d.EndMonth = bll.Model.AccountMonth; bll.Items.Add(d); bll.AddDetail(d); } } }
protected void bt_Delete_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { FNA_FeeWriteOffBLL bll = new FNA_FeeWriteOffBLL((int)ViewState["ID"]); if (bll.Model.State == 1) { bll.Delete(); Response.Redirect("FeeWriteOffList.aspx"); } } }
protected void bt_Save_Click(object sender, EventArgs e) { FNA_FeeWriteOffDetail m = new FNA_FeeWriteOffBLL().GetDetailModel((int)ViewState["ID"]); if (decimal.Parse(tbx_ApproveCost.Text) > m.WriteOffCost) { MessageBox.Show(this, "批复核销金额不能超过申请核销金额!"); return; } decimal OldAdjustCost = m.AdjustCost; decimal AdjustCost = decimal.Parse(tbx_ApproveCost.Text) - m.WriteOffCost; m.AdjustReason = tbx_AdjustReason.Text; m["DeductReason"] = ddl_DeductReason.SelectedValue; if (AdjustCost != OldAdjustCost) { if (rbl_AdjustMode.SelectedValue == "") { MessageBox.Show(this, "请选择正确的调整方式!"); return; } else { FNA_FeeWriteOffDetail_AdjustInfoBLL _Adjustbll = new FNA_FeeWriteOffDetail_AdjustInfoBLL(); _Adjustbll.Model.WriteOffDetailID = (int)ViewState["ID"]; _Adjustbll.Model.AdjustMode = int.Parse(rbl_AdjustMode.SelectedValue); _Adjustbll.Model.AdjustCost = decimal.Parse(tbx_ApproveCost.Text) - m.WriteOffCost; _Adjustbll.Model.AdjustReason = ddl_DeductReason.SelectedValue; _Adjustbll.Model.Remark = tbx_AdjustReason.Text; _Adjustbll.Model.InsertStaff = (int)Session["UserID"]; _Adjustbll.Add(); Session["SuccessFlag"] = true; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "message", "<script language='javascript'>window.close();</script>", false); } } else { MessageBox.Show(this, "批复金额尚没有修改!"); return; } }
private void AddWriteOffDetail(FNA_FeeWriteOffBLL bll, int AccountTitle, Decimal Cost, DateTime minbegindate, DateTime maxenddate) { if (Cost == 0) { return; } FNA_FeeWriteOffDetail d = new FNA_FeeWriteOffDetail(); d.AccountTitle = AccountTitle; d.ApplyCost = 0; d.WriteOffCost = Cost; d.BeginDate = minbegindate; d.EndDate = maxenddate; d.BeginMonth = bll.Model.AccountMonth; d.EndMonth = bll.Model.AccountMonth; bll.Items.Add(d); }
private void BindGrid() { lbl_message.Text = "费用报销审批汇总表"; int id = (int)ViewState["ID"]; FNA_FeeWriteOffBLL bll = new FNA_FeeWriteOffBLL(id); ViewState["Details"] = bll.Items.OrderBy(p => p.Client).ThenBy(p => p.AccountTitle).ThenBy(p => p.BeginMonth).ToList(); FNA_FeeWriteOff writeoff = bll.Model; if (writeoff == null) Response.Redirect("FeeWriteOffList.aspx"); BindGridPrint(); string type = ""; if (writeoff["InvoiceClassAB"] != "") type = DictionaryBLL.GetDicCollections("FNA_InvoiceClassAB")[writeoff["InvoiceClassAB"]].Name; // type = DictionaryBLL.Dictionary_Data_GetAlllList("TableName='FNA_InvoiceClassAB' AND Code='" + writeoff["InvoiceClassAB"] + "'")[0].Name; if (type == "") type = "抵款"; span_sheetcode.InnerText = writeoff.SheetCode; span_accountmonth.InnerText = new AC_AccountMonthBLL(writeoff.AccountMonth).Model.Name; if (bll.Model["InsteadPayStaff"] != "" && bll.Model["InsteadPayStaff"] != "0") { p_ddtype.InnerText = "员工"; span_client.InnerText = new Org_StaffBLL(int.Parse(bll.Model["InsteadPayStaff"])).Model.RealName; } else span_client.InnerText = new CM_ClientBLL(writeoff.InsteadPayClient).Model.FullName; int city5 = TreeTableBLL.GetSuperIDByLevel("MCS_SYS.dbo.Addr_OrganizeCity", writeoff.OrganizeCity, 5); span_orgnizecity.InnerText = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", "ID", "Name", "SuperID", 1, city5 > 0 ? city5 : writeoff.OrganizeCity); span_type.InnerText = type; span1.InnerText = span2.InnerText = "1"; //求费用核消金额合计 decimal _totalcost = 0; foreach (FNA_FeeWriteOffDetail _detail in bll.Items) { _totalcost += _detail.WriteOffCost + _detail.AdjustCost; } lab_SubTotalCostCN.Text = MCSFramework.Common.Rmb.CmycurD(_totalcost.ToString()); lab_SubTotalCost.Text = _totalcost.ToString("#,##0.00"); lab_SubTotalCost.Text = lab_SubTotalCost.Text; lab_SubTotalCost.Text = lab_SubTotalCost.Text; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]); ViewState["DetailID"] = Request.QueryString["DetailID"] == null ? 0 : int.Parse(Request.QueryString["DetailID"]); if ((int)ViewState["ID"] == 0) { MessageBox.ShowAndClose(this, "参数错误!"); return; } if ((int)ViewState["DetailID"] > 0) { FNA_FeeWriteOffDetail m = new FNA_FeeWriteOffBLL().GetDetailModel((int)ViewState["DetailID"]); tbx_Taxes.Text = m.ApplyCost.ToString("#.##"); tbx_Remark.Text = m.Remark; } } }
private void btn_save_Click(object sender, EventArgs e) { DropDownList invoice = pn_FeeWriteOff.FindControl("FNA_FeeWriteOff_InvoiceClassAB") as DropDownList; if (invoice.SelectedValue == "0" || invoice.SelectedValue == "") { MessageBox.Show(this, "请选择抵货款类型!"); return; } FNA_FeeWriteOffBLL writeoff = new FNA_FeeWriteOffBLL((int)ViewState["ID"]); writeoff.Model["InvoiceClassAB"] = invoice.SelectedValue; if (writeoff.Update() >= 0) { MessageBox.Show(this, "调整成功!"); } else { MessageBox.Show(this, "调整失败!"); } }
private void BindData() { FNA_FeeWriteOffDetail m = new FNA_FeeWriteOffBLL().GetDetailModel((int)ViewState["ID"]); lb_AccountTitle.Text = TreeTableBLL.GetFullPathName("MCS_Pub.dbo.AC_AccountTitle", m.AccountTitle); lb_ApplyCost.Text = m.ApplyCost.ToString("0.###"); lb_WriteOffCost.Text = m.WriteOffCost.ToString("0.###"); tbx_ApproveCost.Text = (m.WriteOffCost + m.AdjustCost).ToString("0.###"); rbl_AdjustMode.SelectedValue = m.AdjustMode.ToString(); try { if (new FNA_FeeWriteOffBLL(m.WriteOffID).Model["HasFeeApply"] == "N") { rbl_AdjustMode.Items.FindByValue("1").Enabled = false; //无申请直接核销的单子,不可选择“退回重新再核销” rbl_AdjustMode.Items.FindByValue("2").Selected = true; } } catch { } }
private void BindData() { if ((int)ViewState["DetailID"] != 0) { FNA_FeeWriteOffDetail _model = new FNA_FeeWriteOffBLL().GetDetailModel((int)ViewState["DetailID"]); if (_model == null) { MessageBox.ShowAndClose(this, "请先保存核销单后,再完善发票信息!"); return; } FNA_FeeWriteOff writeoff = new FNA_FeeWriteOffBLL(_model.WriteOffID).Model; FNA_FeeApplyDetail _applydetail; if (_model.ApplyDetailID > 0) { _applydetail = new FNA_FeeApplyBLL().GetDetailModel(_model.ApplyDetailID); lbl_applyCode.Text = new FNA_FeeApplyBLL(_applydetail.ApplyID).Model.SheetCode; lb_AvailCost.Text = (_applydetail.AvailCost).ToString("0.00"); ViewState["AvailCost"] = _applydetail.AvailCost; } lbl_Client.Text = _model.Client > 0 ? new CM_ClientBLL(_model.Client).Model.FullName : ""; ViewState["ClientID"] = _model.Client; ViewState["Month"] = _model.BeginMonth; pn_Detail.BindData(_model); if (writeoff.State == 1) { if (tbx_RebateRate.Text == "" || tbx_RebateRate.Text == "0") { tbx_RebateRate.Text = "100"; } if (tbx_DiscountRate.Text == "") { tbx_DiscountRate.Text = "0"; } if (tbx_InvoiceCost.Text == "") { tbx_InvoiceCost.Text = _model.WriteOffCost.ToString("0.00"); } if (tbx_WriteOffCost2.Text == "") { tbx_WriteOffCost2.Text = "0.00"; } } ComputInvoiceCost(); UploadFile1.RelateID = (int)ViewState["DetailID"]; if (writeoff.State >= 2) { if (bt_ComputeMixRate != null) { bt_ComputeMixRate.Visible = false; } UploadFile1.CanDelete = false; pn_Detail.SetControlsEnable(false); bt_Save.Visible = false; } if (writeoff.State >= 3) { UploadFile1.CanUpload = false; } } }
protected void bt_AddMobileFee_Click(object sender, EventArgs e) { int staffid = 0; int.TryParse(select_MobileStaff.SelectValue, out staffid); if (staffid == 0) { return; } Org_Staff staff = new Org_StaffBLL(staffid).Model; if (staff == null) { return; } if (string.IsNullOrEmpty(staff["ManageInfo11"])) { staff["ManageInfo11"] = "0"; } decimal applycost = 0; decimal.TryParse(staff["ManageInfo11"], out applycost); if (applycost <= 0) { return; } decimal writeoffcost = decimal.Parse(tbx_MobileCost.Text); if (writeoffcost > applycost) { MessageBox.Show(this, "对不起,实际报销金额不能超过申请限额" + lb_MobileApplyCost.Text + "!"); tbx_MobileCost.Text = lb_MobileApplyCost.Text; return; } SaveGrid(); ViewState["MaxID"] = (int)ViewState["MaxID"] + 1; #region 组织手机费核销明细 FNA_FeeWriteOffDetail item = new FNA_FeeWriteOffDetail(); item.ID = (int)ViewState["MaxID"]; item.AccountTitle = ConfigHelper.GetConfigInt("MobileCostACTitle"); item.ApplyCost = applycost; item.WriteOffCost = writeoffcost; item["MobileFeeRelateStaff"] = staff.ID.ToString(); #region 获取当前会计月的开始及截止日期 int month = int.Parse(ddl_MobileCostMonth.SelectedValue); AC_AccountMonth m = new AC_AccountMonthBLL(month).Model; item.BeginMonth = m.ID; item.EndMonth = m.ID; item.BeginDate = m.BeginDate; item.EndDate = m.EndDate; #endregion item.Remark = "员工:" + staff.RealName + ";"; item.Remark += "手机号码:" + staff["Mobile"] + ";月份:" + ddl_MobileCostMonth.SelectedItem.Text + ";限额:" + lb_MobileApplyCost.Text + ";"; if (tbx_MobileRemark.Text != "") { item.Remark += "说明:" + tbx_MobileRemark.Text; } #endregion if (FNA_FeeWriteOffBLL.CheckMobileFeeHasWriteOff(item.AccountTitle, item.BeginMonth, staffid)) { MessageBox.Show(this, "该员工指定月的手机费,已在其他报销单中报销,请勿重复报销!"); } else { ListTable <FNA_FeeWriteOffDetail> _details = ViewState["Details"] as ListTable <FNA_FeeWriteOffDetail>; if (_details.GetListItem().FirstOrDefault(p => p.AccountTitle == item.AccountTitle && p.BeginMonth == item.BeginMonth && p["MobileFeeRelateStaff"] == item["MobileFeeRelateStaff"]) == null) { _details.Add(item); //新增科目 } else { MessageBox.Show(this, "该员工指定月的手机费,已在本报销单中,请勿重复报销!"); } } BindGrid(); AddEmptyDetail(); }
protected void bt_Save_Click(object sender, EventArgs e) { ListTable <FNA_FeeWriteOffDetail> _details; if (ViewState["Details"] != null) { _details = ViewState["Details"] as ListTable <FNA_FeeWriteOffDetail>; } else { _details = new ListTable <FNA_FeeWriteOffDetail>(new FNA_FeeWriteOffBLL((int)ViewState["ID"]).Items, "ID"); } FNA_FeeWriteOffBLL bll; if ((int)ViewState["ID"] == 0) { bll = new FNA_FeeWriteOffBLL(); } else { bll = new FNA_FeeWriteOffBLL((int)ViewState["ID"]); if (bll.Model.State != 1) { MessageBox.ShowAndRedirect(this, "对不起,当前核销单的状态不是“未提交”状态,不可保存!", "FeeWriteOffDetail.aspx?ID=" + ViewState["ID"].ToString()); return; } } pn_FeeWriteOff.GetData(bll.Model); bll.Model["Remark"] = tbx_Remark.Text; #region 效性校验 // 判断是否选择了费用代垫客户或代垫员工 { if (bll.Model["InsteadPaySystem"] == "0") { bll.Model["InsteadPaySystem"] = ""; } if (bll.Model["InsteadPayStaff"] == "0") { bll.Model["InsteadPayStaff"] = ""; } int insteadcount = 0; if (bll.Model.InsteadPayClient != 0) { insteadcount++; } if (!string.IsNullOrEmpty(bll.Model["InsteadPayStaff"])) { insteadcount++; } if (!string.IsNullOrEmpty(bll.Model["InsteadPaySystem"])) { insteadcount++; } if (insteadcount > 1) { MessageBox.Show(this, "代垫信息中,只能填写其中一个代垫信息!"); return; } else if (insteadcount == 0) { MessageBox.Show(this, "代垫信息中,必须填写其中一个代垫信息!"); return; } } #endregion if ((int)ViewState["ID"] == 0) { bll.Model.SheetCode = FNA_FeeWriteOffBLL.GenerateSheetCode((int)ViewState["OrganizeCity"]); //自动产生报销单号 bll.Model.AccountMonth = (int)ViewState["AccountMonth"]; bll.Model.FeeType = (int)ViewState["FeeType"]; bll.Model.OrganizeCity = (int)ViewState["OrganizeCity"]; bll.Model.ApproveFlag = 1; bll.Model.State = 1; bll.Model["HasFeeApply"] = ViewState["HasFeeApply"].ToString(); //是否有申请单 bll.Model["IsEvectionWriteOff"] = "N"; //非关联于差旅行程的报销 bll.Model.InsertStaff = (int)Session["UserID"]; bll.Model["InvoiceClassAB"] = ViewState["InvoiceClassAB"].ToString(); bll.Model["FeeApplyClient"] = ViewState["FeeApplyClient"].ToString(); bll.Model["FeeApplyStaff"] = ViewState["FeeApplyStaff"].ToString(); bll.Items = _details.GetListItem(); ViewState["ID"] = bll.Add(); } else { bll.Model.UpdateStaff = (int)Session["UserID"]; bll.Update(); #region 修改明细 #region 增加报销明细时,再次判断该项费用是否已报销 bll.Items = new List <FNA_FeeWriteOffDetail>(); foreach (FNA_FeeWriteOffDetail item in _details.GetListItem(ItemState.Added)) { FNA_FeeApplyBLL apply = new FNA_FeeApplyBLL(); if (apply.GetDetailModel(item.ApplyDetailID).Flag == 1) { bll.Items.Add(item); } } bll.AddDetail(); #endregion foreach (FNA_FeeWriteOffDetail _deleted in _details.GetListItem(ItemState.Deleted)) { bll.DeleteDetail(_deleted.ID); } bll.Items = _details.GetListItem(ItemState.Modified); bll.UpdateDetail(); #endregion } if (sender != null) { Response.Redirect("FeeWriteOffDetail.aspx?ID=" + ViewState["ID"].ToString()); } }
protected void bt_Submit_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { bt_Save_Click(null, null); FNA_FeeWriteOffBLL bll = new FNA_FeeWriteOffBLL((int)ViewState["ID"]); int KAtitle = ConfigHelper.GetConfigInt("AccountTitle-KA"); foreach (FNA_FeeWriteOffDetail item in bll.Items) { //如果是KA合同则必填票号信息 if (item.AccountTitle == KAtitle && (item["VATInvoiceNO"] == "" || item["InvoiceDate"] == "" || item["AcceptanceNO"] == "" || item["DiscountRate"] == "" || item["DiscountCost"] == "" || item["RebateRate"] == "")) { MessageBox.Show(this, "KA合同核销费用时,必须填写完整票号信息!"); return; } } if (bll.Model.InsteadPayClient == 0 && bll.Model["InsteadPayStaff"] == "" && bll.Model["InsteadPaySystem"] == "") { MessageBox.Show(this, "代垫信息中,必须填写其中一个代垫信息!"); return; } if (bll.Items.Count == 0) { MessageBox.Show(this, "要报销的费用科目明细不能为空,请先添加要报销的费用科目!"); return; } if (bll.Model.State != 1) { MessageBox.ShowAndRedirect(this, "对不起,当前流程的状态不是“未提交”状态,不可再次提交!", "FeeWriteOffDetail.aspx?ID=" + ViewState["ID"].ToString()); return; } #region 发起工作流 NameValueCollection dataobjects = new NameValueCollection(); dataobjects.Add("ID", ViewState["ID"].ToString()); dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString()); dataobjects.Add("AccountMonth", bll.Model.AccountMonth.ToString()); dataobjects.Add("FeeType", bll.Model.FeeType.ToString()); dataobjects.Add("WriteoffCost", lb_TotalCost.Text); dataobjects.Add("InsteadPayClient", bll.Model.InsteadPayClient != 0 ? "1" : "2"); dataobjects.Add("MasterInsteadPayClient", ViewState["MasterInsteadPayClient"] == null ? "0" : ViewState["MasterInsteadPayClient"].ToString()); //组合审批任务主题 Label lb_OrganizeCity = (Label)pn_FeeWriteOff.FindControl("FNA_FeeWriteOff_OrganizeCity"); string title = lb_OrganizeCity.Text + ",核销单号:" + bll.Model.SheetCode + ",申请总额:" + lb_TotalCost.Text; int TaskID = EWF_TaskBLL.NewTask("FNA_FeeWriteoffFlow", (int)Session["UserID"], title, "~/SubModule/FNA/FeeWriteoff/FeeWriteoffDetail.aspx?ID=" + ViewState["ID"].ToString(), dataobjects); if (TaskID > 0) { new EWF_TaskBLL(TaskID).Start(); //直接启动流程 } #endregion bll.Submit((int)Session["UserID"], TaskID); MessageBox.ShowAndRedirect(this, "费用报销单提交成功,请打印报销单,并附贴相关票据!", "FeeWriteOffDetail.aspx?ID=" + ViewState["ID"].ToString()); } }
protected void gv_ListDetail_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int id = (int)gv_ListDetail.DataKeys[e.Row.RowIndex][0]; UC_GridView gv_Detail = (UC_GridView)e.Row.FindControl("gv_Detail"); if (gv_Detail != null) { IList<FNA_FeeWriteOffDetail> lists = new FNA_FeeWriteOffBLL(id).Items; //费用类型 int accounttile = 0; int.TryParse(tr_AccountTitle.SelectValue, out accounttile); if (ddl_FeeType.SelectedValue != "0" && !(accounttile > 1)) { IList<AC_AccountTitleInFeeType> titles = AC_AccountTitleInFeeTypeBLL.GetModelList("FeeType=" + ddl_FeeType.SelectedValue); int[] ids = new int[titles.Count]; for (int i = 0; i < titles.Count; i++) { ids[i] = titles[i].AccountTitle; } lists = lists.Where(p => ids.Contains(p.AccountTitle)).ToList(); } //费用科目 if (accounttile > 1) { DataTable dt = TreeTableBLL.GetAllChildByNodes("MCS_PUB.dbo.AC_AccountTitle", "ID", "SuperID", accounttile.ToString()); int[] ids = new int[dt.Rows.Count + 1]; for (int i = 0; i < dt.Rows.Count; i++) { ids[i] = (int)dt.Rows[i]["ID"]; } ids[ids.Length - 1] = accounttile; lists = lists.Where(p => ids.Contains(p.AccountTitle)).ToList(); } //核销金额判断 decimal _cost = 0; decimal.TryParse(tbx_WriteOffCost.Text, out _cost); if (_cost != 0) { if (ddl_WriteOffCostOP.SelectedValue == ">") lists = lists.Where(p => p.WriteOffCost + p.AdjustCost > _cost).ToList(); else if (ddl_WriteOffCostOP.SelectedValue == "<") lists = lists.Where(p => p.WriteOffCost + p.AdjustCost < _cost).ToList(); } gv_Detail.BindGrid(lists); } } }
private void BindData() { int id = (int)ViewState["ID"]; FNA_FeeWriteOffBLL bll = new FNA_FeeWriteOffBLL(id); ViewState["Details"] = bll.Items.OrderBy(p => p.Client).ToList(); ViewState["FLPurchase"] = FNA_FeeWriteOffBLL.GetPurchaseVolume((int)ViewState["ID"]); FNA_FeeWriteOff writeoff = bll.Model; if (writeoff == null) Response.Redirect("FeeWriteOffList.aspx"); pn_FeeWriteOff.BindData(writeoff); ViewState["AccountMonth"] = writeoff.AccountMonth; ViewState["SheetCode"] = writeoff.SheetCode; ViewState["State"] = writeoff.State; ViewState["HasFeeApply"] = writeoff["HasFeeApply"]; ViewState["IsEvectionWriteOff"] = writeoff["IsEvectionWriteOff"]; ViewState["InsteadPayClient"] = bll.Model.InsteadPayClient; writeoff["Remark"] = writeoff["Remark"].Replace("\r", "<br/>"); detailPrint.Visible = true; if (bll.Model.InsteadPayClient > 0) { BindGridPrint(); string type = ""; if (writeoff["InvoiceClassAB"] != "0" && writeoff["InvoiceClassAB"] != "") try { type = DictionaryBLL.Dictionary_Data_GetAlllList("TableName='FNA_InvoiceClassAB' AND Code='" + writeoff["InvoiceClassAB"] + "'")[0].Name; } catch { } lbl_message.Text = "<font color='red'>" + new CM_ClientBLL((int)ViewState["InsteadPayClient"]).Model.FullName + "</font>代垫费用" + "<font color='red'>" + type + "</font>" + "明细表"; div_client.InnerText = new CM_ClientBLL((int)ViewState["InsteadPayClient"]).Model.FullName; div_type.InnerText = div_type2.InnerText = div_type3.InnerText = div_type0.InnerText = type; div_SheetCode.InnerText = writeoff.SheetCode; } else if (bll.Model["InsteadPayStaff"] != "0" && bll.Model["InsteadPayStaff"] != "") { BindGridPrint(); string type = ""; if (writeoff["InvoiceClassAB"] != "0" && writeoff["InvoiceClassAB"] != "") try { type = DictionaryBLL.Dictionary_Data_GetAlllList("TableName='FNA_InvoiceClassAB' AND Code='" + writeoff["InvoiceClassAB"] + "'")[0].Name; } catch { } lbl_message.Text = "<font color='red'>" + new Org_StaffBLL(int.Parse(writeoff["InsteadPayStaff"])).Model.RealName + "</font>代垫费用" + "<font color='red'>" + type + "</font>" + "明细表"; div_client.InnerText = new Org_StaffBLL(int.Parse(writeoff["InsteadPayStaff"])).Model.RealName; div_type.InnerText = div_type2.InnerText = div_type3.InnerText = div_type0.InnerText = type; div_SheetCode.InnerText = writeoff.SheetCode; div_insType.InnerText = "员工:"; label_insName.InnerText = "该员工"; label_insName2.InnerText = label_insName3.InnerText = "代垫员工"; } writeoff.InsteadPayClient = 0; pn_Remark.BindData(writeoff); //求费用核消金额合计 decimal _totalcost = 0; foreach (FNA_FeeWriteOffDetail _detail in bll.Items) { _totalcost += _detail.WriteOffCost + _detail.AdjustCost; } _totalcost = Math.Round(_totalcost, 1); lb_TotalCostCN.Text = MCSFramework.Common.Rmb.CmycurD(_totalcost.ToString()); lb_TotalCost.Text = _totalcost.ToString("#,##0.00"); lab_TotalCostCN.Text = lb_TotalCostCN.Text; lab_TotalCost.Text = lb_TotalCost.Text; BindGrid(); #region 绑定差旅行程 if (writeoff["IsEvectionWriteOff"] == "Y") { tb_EvectionRouteList.Visible = true; gv_EvectionRouteList.ConditionString = "FNA_EvectionRoute.WriteOffID = " + ViewState["ID"].ToString(); gv_EvectionRouteList.BindGrid(); } #endregion }
protected void gv_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int applydetailid = (int)gv_List.DataKeys[e.Row.RowIndex]["ApplyDetailID"]; if (applydetailid > 0) { string sheetcode = FNA_FeeApplyBLL.GetSheetCodeByDetailID(applydetailid); FNA_FeeApplyDetail applydetail = new FNA_FeeApplyBLL().GetDetailModel(applydetailid); if (applydetail != null) { HyperLink hy_ApplySheetCode = (HyperLink)e.Row.FindControl("hy_ApplySheetCode"); hy_ApplySheetCode.Text = sheetcode; hy_ApplySheetCode.NavigateUrl = "~/SubModule/FNA/FeeApply/FeeApplyDetail3.aspx?ID=" + applydetail.ApplyID; HyperLink hy_TaskApprove = (HyperLink)e.Row.FindControl("hy_TaskApprove"); FNA_FeeApplyBLL bll = new FNA_FeeApplyBLL(applydetail.ApplyID); if (hy_TaskApprove != null && bll.Model.ApproveTask > 0) { hy_TaskApprove.NavigateUrl = "~/SubModule/EWF/TaskDetail.aspx?TaskID=" + bll.Model.ApproveTask; hy_TaskApprove.Visible = true; } if (applydetail.Client > 0) { HyperLink hy_Client = (HyperLink)e.Row.FindControl("hy_Client"); hy_Client.Text = new CM_ClientBLL(applydetail.Client).Model.FullName; hy_Client.NavigateUrl = "~/SubModule/FNA/FeeApplyOrWriteoffByClientList.aspx?ClientID=" + applydetail.Client; } if (applydetail.AccountTitle == 82 && ViewState["ID"] != null && (int)ViewState["ID"] > 0) { Object obj_lab = e.Row.FindControl("lb_DeductReason"); if (obj_lab != null && ViewState["FLPurchase"] != null) { e.Row.Cells[7].Text = "总进货额:" + ((DataTable)ViewState["FLPurchase"]).Compute("Sum(PurchaseVolume)", "ID=" + gv_List.DataKeys[e.Row.RowIndex]["ID"]).ToString() + ";\n" + e.Row.Cells[7].Text; } } } } int id = (int)gv_List.DataKeys[e.Row.RowIndex]["ID"]; if (id > 0) { Button bt_OpenAdjust = e.Row.FindControl("bt_OpenAdjust") != null ? (Button)e.Row.FindControl("bt_OpenAdjust") : null; if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y") { bt_OpenAdjust.OnClientClick = "PopAdjust(" + id.ToString() + ")"; bt_OpenAdjust.Visible = true; } FNA_FeeWriteOffDetail writedetail = new FNA_FeeWriteOffBLL().GetDetailModel(id); if (applydetailid == 0) { Button btn_Attachment = e.Row.FindControl("btn_Attachment") != null ? (Button)e.Row.FindControl("btn_Attachment") : null; if (btn_Attachment != null) { btn_Attachment.Visible = false; } HyperLink hy_Client = (HyperLink)e.Row.FindControl("hy_Client"); CM_Client client = new CM_ClientBLL(writedetail.Client).Model; hy_Client.Text = client == null || string.IsNullOrEmpty(client.FullName) ? string.Empty : client.FullName; hy_Client.NavigateUrl = "~/SubModule/FNA/FeeApplyOrWriteoffByClientList.aspx?ClientID=" + writedetail.Client; bt_OpenAdjust.Visible = false; } } } }
protected void bt_WriteOff_Click(object sender, EventArgs e) { #region 求选中行的差旅费、住宿费、补贴合计 decimal Cost1 = 0, Cost2 = 0, Cost3 = 0, Cost4 = 0, Cost5 = 0; decimal Cost11 = 0, Cost12 = 0, Cost13 = 0; //车辆费用 decimal Cost21 = 0, Cost22 = 0; DateTime minbegindate = DateTime.Parse("2999-1-1"), maxenddate = DateTime.Parse("1900-1-1"); List<int> selectedevectionids = new List<int>(); foreach (GridViewRow row in gv_List.Rows) { CheckBox cbx = (CheckBox)row.FindControl("cbx"); if (cbx != null && cbx.Checked) { int id = (int)gv_List.DataKeys[row.RowIndex][0]; FNA_EvectionRoute evection = new FNA_EvectionRouteBLL(id).Model; #region 根据关联的工作日志的类型,判断是否培训费 //获取关联的日志类型 int journalid = 0, workingclassify = 0; if (int.TryParse(evection["RelateJournal"], out journalid) && journalid > 0) { JN_Journal Joural = new JN_JournalBLL(journalid).Model; if (Joural != null) workingclassify = Joural.WorkingClassify; } switch (workingclassify) { case 4: //总部组织的培训,计入总部培训-差旅费 Cost21 += evection.Cost1 + evection.Cost2 + evection.Cost3 + evection.Cost4 + evection.Cost5; break; case 5: //省区组织的培训,计入营业部培训-差旅费 Cost22 += evection.Cost1 + evection.Cost2 + evection.Cost3 + evection.Cost4 + evection.Cost5; break; default: Cost1 += evection.Cost1; //交通费 Cost2 += evection.Cost2; //住宿费 Cost3 += evection.Cost3; //补贴 Cost4 += evection.Cost4; //市内交通费 Cost5 += evection.Cost5; //的士费 break; } #endregion if (minbegindate > evection.BeginDate) minbegindate = evection.BeginDate; if (maxenddate < evection.EndDate) maxenddate = evection.EndDate; int cardispatchid = 0; if (int.TryParse(gv_List.DataKeys[row.RowIndex]["Car_DispatchRide_ID"].ToString(), out cardispatchid) && cardispatchid > 0) { Car_DispatchRide dispatch = new Car_DispatchRideBLL(cardispatchid).Model; if (dispatch != null) { Cost11 += dispatch.RoadToll; //过路过桥费 Cost12 += dispatch.FuelFee; //油费 Cost13 += dispatch.ParkingFee; //停车费 Cost13 += dispatch.OtherFee; //其他费 } } selectedevectionids.Add(id); } } if (Cost1 + Cost2 + Cost3 + Cost4 + Cost5 + Cost11 + Cost12 + Cost13 + Cost21 + Cost22 == 0) { MessageBox.Show(this, "对不起,请勾选要报销的差旅行程记录!"); return; } #endregion #region 新增费用核销单头 Org_Staff staff = new Org_StaffBLL((int)Session["UserID"]).Model; FNA_FeeWriteOffBLL bll = new FNA_FeeWriteOffBLL(); bll.Model.SheetCode = FNA_FeeWriteOffBLL.GenerateSheetCode(staff.OrganizeCity); //自动产生报销单号 bll.Model.AccountMonth = AC_AccountMonthBLL.GetCurrentMonth(); bll.Model.FeeType = ConfigHelper.GetConfigInt("EvectionFeeType"); //差旅费对应的费用类型 bll.Model.OrganizeCity = staff.OrganizeCity; bll.Model.ApproveFlag = 1; bll.Model.State = 1; bll.Model.InsertStaff = (int)Session["UserID"]; bll.Model["HasFeeApply"] = "N"; //无申请单 bll.Model["IsEvectionWriteOff"] = "Y"; //是差旅报销 #endregion #region 新增费用核销单明细 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost1ACTitle"), Cost1, minbegindate, maxenddate);//交通费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost2ACTitle"), Cost2, minbegindate, maxenddate);//住宿费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost3ACTitle"), Cost3, minbegindate, maxenddate);//补贴 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost4ACTitle"), Cost4, minbegindate, maxenddate);//市内交通费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost5ACTitle"), Cost5, minbegindate, maxenddate);//的士费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost11ACTitle"), Cost11, minbegindate, maxenddate);//车辆费用-路桥费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost12ACTitle"), Cost12, minbegindate, maxenddate);//车辆费用-油费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost13ACTitle"), Cost13, minbegindate, maxenddate);//车辆费用-其他杂费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("TrainingCost1ACTitle"), Cost21, minbegindate, maxenddate);//总部培训费-差旅费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("TrainingCost2ACTitle"), Cost22, minbegindate, maxenddate);//营业部培训费-差旅费 #endregion int writeoff = bll.Add(); #region 置差旅行程的关联报销单ID foreach (int evectionid in selectedevectionids) { FNA_EvectionRouteBLL evectionbll = new FNA_EvectionRouteBLL(evectionid); evectionbll.Model.WriteOffID = writeoff; evectionbll.Update(); } #endregion Response.Redirect("FeeWriteoffDetail.aspx?ID=" + writeoff.ToString()); }
private void AddWriteOffDetail(FNA_FeeWriteOffBLL bll, int AccountTitle, Decimal Cost, DateTime minbegindate, DateTime maxenddate) { if (Cost == 0) return; FNA_FeeWriteOffDetail d = new FNA_FeeWriteOffDetail(); d.AccountTitle = AccountTitle; d.ApplyCost = 0; d.WriteOffCost = Cost; d.BeginDate = minbegindate; d.EndDate = maxenddate; d.BeginMonth = bll.Model.AccountMonth; d.EndMonth = bll.Model.AccountMonth; bll.Items.Add(d); }
private void BindData() { int id = (int)ViewState["ID"]; FNA_FeeWriteOffBLL bll = new FNA_FeeWriteOffBLL(id); ViewState["Details"] = bll.Items.OrderBy(p => p.Client).ToList(); ViewState["FLPurchase"] = FNA_FeeWriteOffBLL.GetPurchaseVolume((int)ViewState["ID"]); FNA_FeeWriteOff writeoff = bll.Model; if (writeoff == null) { Response.Redirect("FeeWriteOffList.aspx"); } pn_FeeWriteOff.BindData(writeoff); ViewState["AccountMonth"] = writeoff.AccountMonth; ViewState["SheetCode"] = writeoff.SheetCode; ViewState["State"] = writeoff.State; ViewState["HasFeeApply"] = writeoff["HasFeeApply"]; ViewState["IsEvectionWriteOff"] = writeoff["IsEvectionWriteOff"]; ViewState["InsteadPayClient"] = bll.Model.InsteadPayClient; writeoff["Remark"] = writeoff["Remark"].Replace("\r", "<br/>"); detailPrint.Visible = true; if (bll.Model.InsteadPayClient > 0) { BindGridPrint(); string type = ""; if (writeoff["InvoiceClassAB"] != "0" && writeoff["InvoiceClassAB"] != "") { try { type = DictionaryBLL.Dictionary_Data_GetAlllList("TableName='FNA_InvoiceClassAB' AND Code='" + writeoff["InvoiceClassAB"] + "'")[0].Name; } catch { } } lbl_message.Text = "<font color='red'>" + new CM_ClientBLL((int)ViewState["InsteadPayClient"]).Model.FullName + "</font>代垫费用" + "<font color='red'>" + type + "</font>" + "明细表"; div_client.InnerText = new CM_ClientBLL((int)ViewState["InsteadPayClient"]).Model.FullName; div_type.InnerText = div_type2.InnerText = div_type3.InnerText = div_type0.InnerText = type; div_SheetCode.InnerText = writeoff.SheetCode; } else if (bll.Model["InsteadPayStaff"] != "0" && bll.Model["InsteadPayStaff"] != "") { BindGridPrint(); string type = ""; if (writeoff["InvoiceClassAB"] != "0" && writeoff["InvoiceClassAB"] != "") { try { type = DictionaryBLL.Dictionary_Data_GetAlllList("TableName='FNA_InvoiceClassAB' AND Code='" + writeoff["InvoiceClassAB"] + "'")[0].Name; } catch { } } lbl_message.Text = "<font color='red'>" + new Org_StaffBLL(int.Parse(writeoff["InsteadPayStaff"])).Model.RealName + "</font>代垫费用" + "<font color='red'>" + type + "</font>" + "明细表"; div_client.InnerText = new Org_StaffBLL(int.Parse(writeoff["InsteadPayStaff"])).Model.RealName; div_type.InnerText = div_type2.InnerText = div_type3.InnerText = div_type0.InnerText = type; div_SheetCode.InnerText = writeoff.SheetCode; div_insType.InnerText = "员工:"; label_insName.InnerText = "该员工"; label_insName2.InnerText = label_insName3.InnerText = "代垫员工"; } writeoff.InsteadPayClient = 0; pn_Remark.BindData(writeoff); //求费用核消金额合计 decimal _totalcost = 0; foreach (FNA_FeeWriteOffDetail _detail in bll.Items) { _totalcost += _detail.WriteOffCost + _detail.AdjustCost; } _totalcost = Math.Round(_totalcost, 1); lb_TotalCostCN.Text = MCSFramework.Common.Rmb.CmycurD(_totalcost.ToString()); lb_TotalCost.Text = _totalcost.ToString("#,##0.00"); lab_TotalCostCN.Text = lb_TotalCostCN.Text; lab_TotalCost.Text = lb_TotalCost.Text; BindGrid(); #region 绑定差旅行程 if (writeoff["IsEvectionWriteOff"] == "Y") { tb_EvectionRouteList.Visible = true; gv_EvectionRouteList.ConditionString = "FNA_EvectionRoute.WriteOffID = " + ViewState["ID"].ToString(); gv_EvectionRouteList.BindGrid(); } #endregion }
protected void gv_ListDetail_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int applydetailid = (int)gv_ListDetail.DataKeys[e.Row.RowIndex]["ApplyDetailID"]; if (applydetailid > 0) { Label lb_ApplySheetCode = (Label)e.Row.FindControl("lb_ApplySheetCode"); if (lb_ApplySheetCode != null) { lb_ApplySheetCode.Text = FNA_FeeApplyBLL.GetSheetCodeByDetailID(applydetailid); } FNA_FeeApplyDetail _detail = new FNA_FeeApplyBLL().GetDetailModel(applydetailid); FNA_FeeWriteOffDetail _writeoffdetail = new FNA_FeeWriteOffBLL().GetDetailModel((int)gv_ListDetail.DataKeys[e.Row.RowIndex]["ID"]); Label lb_AllCost = (Label)e.Row.FindControl("lb_AllCost"); if (lb_AllCost != null) { lb_AllCost.Text = Math.Round(decimal.Parse(_detail["DICost"] == "" ? "0" : _detail["DICost"]) + _detail.ApplyCost, 1).ToString("0.##"); } Label lb_Remark = (Label)e.Row.FindControl("lb_Remark"); if (lb_Remark != null) { try { if (_detail.AccountTitle == 80) //导购工资 { lb_Remark.Text = _detail.Remark.Replace("-", "<br/>"); } else if (_detail.AccountTitle == 82)//无导返利 { lb_Remark.Text = _detail["FLRemark"]; if (ViewState["FLPurchase"] != null) { lb_Remark.Text = "进货额:" + ((DataTable)ViewState["FLPurchase"]).Compute("Sum(PurchaseVolume)", "ID=" + _writeoffdetail.ID).ToString() + ";" + _detail["FLRemark"]; } } else { lb_Remark.Text = _writeoffdetail.Remark; } } catch (Exception) { lb_Remark.Text = _writeoffdetail.Remark; } } Label lb_RelateBrand = (Label)e.Row.FindControl("lb_RelateBrand"); if (lb_RelateBrand != null) { string[] brands = new FNA_FeeApplyBLL().GetDetailModel(applydetailid).RelateBrands.Split (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); lb_RelateBrand.Text = ""; foreach (string b in brands) { lb_RelateBrand.Text += new PDT_BrandBLL(int.Parse(b)).Model.Name + ","; } } int client = (int)((UC_GridView)sender).DataKeys[e.Row.RowIndex]["Client"]; if (client > 0) { Label lb_RTChannel = (Label)e.Row.FindControl("lb_RTChannel"); CM_Client c = new CM_ClientBLL(client).Model; if (c != null && c.ClientType == 3 && c["RTChannel"] != "" && lb_RTChannel != null) { if (DictionaryBLL.GetDicCollections("CM_RT_Channel").Keys.Contains(c["RTChannel"])) { lb_RTChannel.Text = DictionaryBLL.GetDicCollections("CM_RT_Channel")[c["RTChannel"]].ToString(); } } } } } }
private void BindData() { int id = (int)ViewState["ID"]; FNA_FeeWriteOff writeoff = new FNA_FeeWriteOffBLL(id).Model; if (writeoff == null) Response.Redirect("FeeWriteOffList.aspx"); if (writeoff["InvoiceClassAB"] == "1") { string Detailid = "0"; FNA_FeeWriteOffDetail _Taxes = new FNA_FeeWriteOffBLL(id).Items.FirstOrDefault(p => p.AccountTitle == 129); if (_Taxes != null) Detailid = _Taxes.ID.ToString(); bt_Taxes.OnClientClick = "PopEditTaxes(" + ViewState["ID"].ToString() + "," + Detailid + ")"; } else { bt_Taxes.Visible = false; } ViewState["AccountMonth"] = writeoff.AccountMonth; ViewState["OrganizeCity"] = writeoff.OrganizeCity; ViewState["InsteadPayClient"] = writeoff.InsteadPayClient; ViewState["FeeType"] = writeoff.FeeType; ViewState["HasFeeApply"] = writeoff["HasFeeApply"]; pn_FeeWriteOff.BindData(writeoff); #region 绑定代垫客户的主户头 ViewState["MasterInsteadPayClient"] = 0; if (ViewState["InsteadPayClient"] != null && (int)ViewState["InsteadPayClient"] > 0) { CM_Client client = new CM_ClientBLL((int)ViewState["InsteadPayClient"]).Model; if (client != null && client.ClientType == 2 && client["DIClassify"] == "3") { CM_Client supplier = new CM_ClientBLL(client.Supplier).Model; if (supplier != null && supplier.ClientType == 2 && supplier["DIClassify"] == "1") { HyperLink hy_MasterAccountName = new HyperLink(); hy_MasterAccountName.NavigateUrl = "~/SubModule/CM/DI/DistributorDetail.aspx?ClientID=" + supplier.ID.ToString(); hy_MasterAccountName.Target = "_blank"; hy_MasterAccountName.Text = "关联主户头:" + supplier.FullName; hy_MasterAccountName.ForeColor = System.Drawing.Color.Blue; pn_FeeWriteOff.FindControl("FNA_FeeWriteOff_InsteadPayClient").Parent.Controls.Add(hy_MasterAccountName); ViewState["MasterInsteadPayClient"] = supplier.ID; } } } #endregion UploadFile1.RelateID = (int)ViewState["ID"]; #region 根据审批状态控制页面 if (writeoff.State == 1) { tbx_Remark.Text = writeoff["Remark"]; tbl_Remark.Visible = true; bt_Print.Visible = false; } if (writeoff.State != 1) { //非 未提交 状态 bt_EditWriteOffDetail.Visible = false; bt_AddTitleNoApply.Visible = false; pn_FeeWriteOff.SetPanelEnable("Panel_FNA_FeeWriteOffDetail_1", false); gv_List.Columns[gv_List.Columns.Count - 1].Visible = false; //不可删除 bt_Save.Visible = false; bt_Submit.Visible = false; bt_Delete.Visible = false; writeoff["Remark"] = writeoff["Remark"].Replace("\r", "<br/>"); pn_Remark.BindData(writeoff); pn_Remark.Visible = true; bt_Print.Visible = true; UploadFile1.CanDelete = false; bt_Taxes.Visible = false; //可见调整金额及原因 gv_List.Columns[gv_List.Columns.Count - 6].Visible = true; //扣减备注 gv_List.Columns[gv_List.Columns.Count - 7].Visible = true; //扣减原因 gv_List.Columns[gv_List.Columns.Count - 8].Visible = true; //扣减方式 gv_List.Columns[gv_List.Columns.Count - 9].Visible = true; //扣减金额 gv_List.Columns[gv_List.Columns.Count - 10].Visible = true; //是否逾期 } if (writeoff.State == 2) { //已提交状态 //审批过程中,可以作金额调整 Decision参数为在审批过程中传进来的参数 if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y") { gv_List.Columns[gv_List.Columns.Count - 5].Visible = true; //调整按钮 bt_Taxes.Visible = true; } } if (writeoff.State != 3 && Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1503, "ModifyInfoAB")) { //非已审核状态可以调整 if (pn_FeeWriteOff.FindControl("FNA_FeeWriteOff_InvoiceClassAB") != null) { DropDownList invoice = pn_FeeWriteOff.FindControl("FNA_FeeWriteOff_InvoiceClassAB") as DropDownList; invoice.Enabled = true; Button btn_save = pn_FeeWriteOff.FindControl("btn_saveAB") as Button; btn_save.Visible = true; btn_save.Enabled = true; } } //上传附件 gv_List.Columns[gv_List.Columns.Count - 3].Visible = (writeoff.InsertStaff == (int)Session["UserID"] && writeoff.State == 1) || (writeoff.State < 3 && Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1503, "AddAttachment")); if (writeoff.InsertStaff != (int)Session["UserID"] || writeoff.State >= 3) { UploadFile1.CanUpload = false; UploadFile1.CanDelete = false; gv_List.Columns[gv_List.Columns.Count - 2].Visible = true;//附件 } #endregion SetGridViewColumnAndButton(writeoff["HasFeeApply"] != "N", writeoff["IsEvectionWriteOff"] == "Y", writeoff.State); BindGrid(); }
protected void bt_AddTeleFee_Click(object sender, EventArgs e) { if (ddl_Tele.SelectedValue == "0") { return; } int teleid = int.Parse(ddl_Tele.SelectedValue); CM_PropertyInTelephone tele = new CM_PropertyInTelephoneBLL(teleid).Model; decimal writeoffcost = decimal.Parse(tbx_TeleCost.Text); decimal applycost = tele.TeleCost + tele.NetCost; if (writeoffcost > applycost) { MessageBox.Show(this, "对不起,实际报销金额不能超过申请限额" + lb_TeleApplyCost.Text + "!"); tbx_TeleCost.Text = lb_TeleApplyCost.Text; return; } SaveGrid(); ViewState["MaxID"] = (int)ViewState["MaxID"] + 1; #region 组织电话费核销明细 FNA_FeeWriteOffDetail item = new FNA_FeeWriteOffDetail(); item.ID = (int)ViewState["MaxID"]; item.AccountTitle = ConfigHelper.GetConfigInt("TeleCostACTitle"); item.ApplyCost = applycost; item.WriteOffCost = writeoffcost; item["TeleFeeRelateTelephone"] = tele.ID.ToString(); item.Client = tele.Client; #region 获取当前会计月的开始及截止日期 int month = int.Parse(ddl_TeleCostMonth.SelectedValue); AC_AccountMonth m = new AC_AccountMonthBLL(month).Model; item.BeginMonth = m.ID; item.EndMonth = m.ID; item.BeginDate = m.BeginDate; item.EndDate = m.EndDate; #endregion if (tele.Client > 0) { CM_Client client = new CM_ClientBLL(tele.Client).Model; if (client != null) { item.Remark = "物业:" + client.FullName + ";"; } } item.Remark += "电话号码:" + ddl_Tele.SelectedItem.Text + ";月份:" + ddl_TeleCostMonth.SelectedItem.Text + ";限额:" + lb_TeleApplyInfo.Text + ";"; if (tbx_TeleRemark.Text != "") { item.Remark += "说明:" + tbx_TeleRemark.Text; } #endregion if (FNA_FeeWriteOffBLL.CheckTeleFeeHasWriteOff(item.AccountTitle, item.BeginMonth, tele.ID)) { MessageBox.Show(this, "该电话指定月的费用,已在其他报销单中报销,请勿重复报销!"); } else { ListTable <FNA_FeeWriteOffDetail> _details = ViewState["Details"] as ListTable <FNA_FeeWriteOffDetail>; if (_details.GetListItem().FirstOrDefault(p => p.AccountTitle == item.AccountTitle && p.BeginMonth == item.BeginMonth && p["TeleFeeRelateTelephone"] == item["TeleFeeRelateTelephone"]) == null) { _details.Add(item); //新增科目 } else { MessageBox.Show(this, "该电话指定月的费用,已在本报销单中,请勿重复报销!"); } } BindGrid(); AddEmptyDetail(); }
private void UpdateDetail(FNA_FeeWriteOffBLL bll, int AccountTitle, Decimal Cost, int flag, DateTime minbegindate, DateTime maxenddate) { if (Cost == 0) return; FNA_FeeWriteOffDetail d = bll.Items.FirstOrDefault(p => p.AccountTitle == AccountTitle); if (d != null) { if (flag == 1) { d.WriteOffCost += Cost; if (d.BeginDate > minbegindate) d.BeginDate = minbegindate; if (d.EndDate < maxenddate) d.EndDate = maxenddate; } else { d.WriteOffCost -= Cost; } if (d.WriteOffCost == 0) bll.DeleteDetail(d.ID); else bll.UpdateDetail(d); } else { if (flag == 1) { d = new FNA_FeeWriteOffDetail(); d.AccountTitle = AccountTitle; d.ApplyCost = 0; d.WriteOffCost = Cost; d.BeginDate = minbegindate; d.EndDate = maxenddate; d.BeginMonth = bll.Model.AccountMonth; d.EndMonth = bll.Model.AccountMonth; bll.Items.Add(d); bll.AddDetail(d); } } }
protected void gv_ListDetail_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int applydetailid = (int)gv_ListDetail.DataKeys[e.Row.RowIndex]["ApplyDetailID"]; if (applydetailid > 0) { Label lb_ApplySheetCode = (Label)e.Row.FindControl("lb_ApplySheetCode"); if (lb_ApplySheetCode != null) lb_ApplySheetCode.Text = FNA_FeeApplyBLL.GetSheetCodeByDetailID(applydetailid); FNA_FeeApplyDetail _detail = new FNA_FeeApplyBLL().GetDetailModel(applydetailid); FNA_FeeWriteOffDetail _writeoffdetail = new FNA_FeeWriteOffBLL().GetDetailModel((int)gv_ListDetail.DataKeys[e.Row.RowIndex]["ID"]); Label lb_AllCost = (Label)e.Row.FindControl("lb_AllCost"); if (lb_AllCost != null) lb_AllCost.Text = Math.Round(decimal.Parse(_detail["DICost"] == "" ? "0" : _detail["DICost"]) + _detail.ApplyCost, 1).ToString("0.##"); Label lb_Remark = (Label)e.Row.FindControl("lb_Remark"); if (lb_Remark != null) { try { if (_detail.AccountTitle == 80) //导购工资 { lb_Remark.Text = _detail.Remark.Replace("-", "<br/>"); } else if (_detail.AccountTitle == 82)//无导返利 { lb_Remark.Text = _detail["FLRemark"]; if (ViewState["FLPurchase"] != null) lb_Remark.Text = "进货额:" + ((DataTable)ViewState["FLPurchase"]).Compute("Sum(PurchaseVolume)", "ID=" + _writeoffdetail.ID).ToString() + ";" + _detail["FLRemark"]; } else { lb_Remark.Text = _writeoffdetail.Remark; } } catch (Exception) { lb_Remark.Text = _writeoffdetail.Remark; } } Label lb_RelateBrand = (Label)e.Row.FindControl("lb_RelateBrand"); if (lb_RelateBrand != null) { string[] brands = new FNA_FeeApplyBLL().GetDetailModel(applydetailid).RelateBrands.Split (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); lb_RelateBrand.Text = ""; foreach (string b in brands) { lb_RelateBrand.Text += new PDT_BrandBLL(int.Parse(b)).Model.Name + ","; } } int client = (int)((UC_GridView)sender).DataKeys[e.Row.RowIndex]["Client"]; if (client > 0) { Label lb_RTChannel = (Label)e.Row.FindControl("lb_RTChannel"); CM_Client c = new CM_ClientBLL(client).Model; if (c != null && c.ClientType == 3 && c["RTChannel"] != "" && lb_RTChannel != null) { if (DictionaryBLL.GetDicCollections("CM_RT_Channel").Keys.Contains(c["RTChannel"])) lb_RTChannel.Text = DictionaryBLL.GetDicCollections("CM_RT_Channel")[c["RTChannel"]].ToString(); } } } } }
protected void bt_Save_Click(object sender, EventArgs e) { ListTable<FNA_FeeWriteOffDetail> _details; if (ViewState["Details"] != null) _details = ViewState["Details"] as ListTable<FNA_FeeWriteOffDetail>; else _details = new ListTable<FNA_FeeWriteOffDetail>(new FNA_FeeWriteOffBLL((int)ViewState["ID"]).Items, "ID"); FNA_FeeWriteOffBLL bll; if ((int)ViewState["ID"] == 0) bll = new FNA_FeeWriteOffBLL(); else { bll = new FNA_FeeWriteOffBLL((int)ViewState["ID"]); if (bll.Model.State != 1) { MessageBox.ShowAndRedirect(this, "对不起,当前核销单的状态不是“未提交”状态,不可保存!", "FeeWriteOffDetail.aspx?ID=" + ViewState["ID"].ToString()); return; } } pn_FeeWriteOff.GetData(bll.Model); bll.Model["Remark"] = tbx_Remark.Text; #region 有效性校验 // 判断是否选择了费用代垫客户或代垫员工 { if (bll.Model["InsteadPaySystem"] == "0") bll.Model["InsteadPaySystem"] = ""; if (bll.Model["InsteadPayStaff"] == "0") bll.Model["InsteadPayStaff"] = ""; int insteadcount = 0; if (bll.Model.InsteadPayClient != 0) insteadcount++; if (!string.IsNullOrEmpty(bll.Model["InsteadPayStaff"])) insteadcount++; if (!string.IsNullOrEmpty(bll.Model["InsteadPaySystem"])) insteadcount++; if (insteadcount > 1) { MessageBox.Show(this, "代垫信息中,只能填写其中一个代垫信息!"); return; } else if (insteadcount == 0) { MessageBox.Show(this, "代垫信息中,必须填写其中一个代垫信息!"); return; } } #endregion if ((int)ViewState["ID"] == 0) { bll.Model.SheetCode = FNA_FeeWriteOffBLL.GenerateSheetCode((int)ViewState["OrganizeCity"]); //自动产生报销单号 bll.Model.AccountMonth = (int)ViewState["AccountMonth"]; bll.Model.FeeType = (int)ViewState["FeeType"]; bll.Model.OrganizeCity = (int)ViewState["OrganizeCity"]; bll.Model.ApproveFlag = 1; bll.Model.State = 1; bll.Model["HasFeeApply"] = ViewState["HasFeeApply"].ToString(); //是否有申请单 bll.Model["IsEvectionWriteOff"] = "N"; //非关联于差旅行程的报销 bll.Model.InsertStaff = (int)Session["UserID"]; bll.Model["InvoiceClassAB"] = ViewState["InvoiceClassAB"].ToString(); bll.Model["FeeApplyClient"] = ViewState["FeeApplyClient"].ToString(); bll.Model["FeeApplyStaff"] = ViewState["FeeApplyStaff"].ToString(); bll.Items = _details.GetListItem(); ViewState["ID"] = bll.Add(); } else { bll.Model.UpdateStaff = (int)Session["UserID"]; bll.Update(); #region 修改明细 #region 增加报销明细时,再次判断该项费用是否已报销 bll.Items = new List<FNA_FeeWriteOffDetail>(); foreach (FNA_FeeWriteOffDetail item in _details.GetListItem(ItemState.Added)) { FNA_FeeApplyBLL apply = new FNA_FeeApplyBLL(); if (apply.GetDetailModel(item.ApplyDetailID).Flag == 1) { bll.Items.Add(item); } } bll.AddDetail(); #endregion foreach (FNA_FeeWriteOffDetail _deleted in _details.GetListItem(ItemState.Deleted)) { bll.DeleteDetail(_deleted.ID); } bll.Items = _details.GetListItem(ItemState.Modified); bll.UpdateDetail(); #endregion } if (sender != null) Response.Redirect("FeeWriteOffDetail.aspx?ID=" + ViewState["ID"].ToString()); }
protected void gv_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int applydetailid = (int)gv_List.DataKeys[e.Row.RowIndex]["ApplyDetailID"]; if (applydetailid > 0) { string sheetcode = FNA_FeeApplyBLL.GetSheetCodeByDetailID(applydetailid); FNA_FeeApplyDetail applydetail = new FNA_FeeApplyBLL().GetDetailModel(applydetailid); if (applydetail != null) { HyperLink hy_ApplySheetCode = (HyperLink)e.Row.FindControl("hy_ApplySheetCode"); hy_ApplySheetCode.Text = sheetcode; hy_ApplySheetCode.NavigateUrl = "~/SubModule/FNA/FeeApply/FeeApplyDetail3.aspx?ID=" + applydetail.ApplyID; HyperLink hy_TaskApprove = (HyperLink)e.Row.FindControl("hy_TaskApprove"); FNA_FeeApplyBLL bll = new FNA_FeeApplyBLL(applydetail.ApplyID); if (hy_TaskApprove != null && bll.Model.ApproveTask > 0) { hy_TaskApprove.NavigateUrl = "~/SubModule/EWF/TaskDetail.aspx?TaskID=" + bll.Model.ApproveTask; hy_TaskApprove.Visible = true; } if (applydetail.Client > 0) { HyperLink hy_Client = (HyperLink)e.Row.FindControl("hy_Client"); hy_Client.Text = new CM_ClientBLL(applydetail.Client).Model.FullName; hy_Client.NavigateUrl = "~/SubModule/FNA/FeeApplyOrWriteoffByClientList.aspx?ClientID=" + applydetail.Client; } if (applydetail.AccountTitle == 82 && ViewState["ID"] != null && (int)ViewState["ID"] > 0) { Object obj_lab = e.Row.FindControl("lb_DeductReason"); if (obj_lab != null && ViewState["FLPurchase"] != null) e.Row.Cells[7].Text = "总进货额:" + ((DataTable)ViewState["FLPurchase"]).Compute("Sum(PurchaseVolume)", "ID=" + gv_List.DataKeys[e.Row.RowIndex]["ID"]).ToString() + ";\n" + e.Row.Cells[7].Text; } } } int id = (int)gv_List.DataKeys[e.Row.RowIndex]["ID"]; if (id > 0) { Button bt_OpenAdjust = e.Row.FindControl("bt_OpenAdjust") != null ? (Button)e.Row.FindControl("bt_OpenAdjust") : null; if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y") { bt_OpenAdjust.OnClientClick = "PopAdjust(" + id.ToString() + ")"; bt_OpenAdjust.Visible = true; } FNA_FeeWriteOffDetail writedetail = new FNA_FeeWriteOffBLL().GetDetailModel(id); if (applydetailid == 0) { Button btn_Attachment = e.Row.FindControl("btn_Attachment") != null ? (Button)e.Row.FindControl("btn_Attachment") : null; if (btn_Attachment != null) btn_Attachment.Visible = false; HyperLink hy_Client = (HyperLink)e.Row.FindControl("hy_Client"); CM_Client client = new CM_ClientBLL(writedetail.Client).Model; hy_Client.Text = client == null || string.IsNullOrEmpty(client.FullName) ? string.Empty : client.FullName; hy_Client.NavigateUrl = "~/SubModule/FNA/FeeApplyOrWriteoffByClientList.aspx?ClientID=" + writedetail.Client; bt_OpenAdjust.Visible = false; } } } }
private void ReComputeCost(int flag) { decimal Cost1 = 0, Cost2 = 0, Cost3 = 0, Cost4 = 0, Cost5 = 0; decimal Cost11 = 0, Cost12 = 0, Cost13 = 0; //车辆费用 decimal Cost21 = 0, Cost22 = 0; //培训差旅费 DateTime minbegindate = DateTime.Parse("2999-1-1"), maxenddate = DateTime.Parse("1900-1-1"); #region 求选中行的差旅费、住宿费、补贴合计 List <int> selectedevectionids = new List <int>(); foreach (GridViewRow row in gv_List.Rows) { CheckBox cbx = (CheckBox)row.FindControl("cbx"); if (cbx != null && cbx.Checked) { int id = (int)gv_List.DataKeys[row.RowIndex][0]; FNA_EvectionRoute evection = new FNA_EvectionRouteBLL(id).Model; #region 根据关联的工作日志的类型,判断是否培训费 //获取关联的日志类型 int journalid = 0, workingclassify = 0; if (int.TryParse(evection["RelateJournal"], out journalid) && journalid > 0) { JN_Journal Joural = new JN_JournalBLL(journalid).Model; if (Joural != null) { workingclassify = Joural.WorkingClassify; } } switch (workingclassify) { case 4: //总部组织的培训,计入总部培训-差旅费 Cost21 += evection.Cost1 + evection.Cost2 + evection.Cost3 + evection.Cost4 + evection.Cost5; break; case 5: //省区组织的培训,计入营业部培训-差旅费 Cost22 += evection.Cost1 + evection.Cost2 + evection.Cost3 + evection.Cost4 + evection.Cost5; break; default: Cost1 += evection.Cost1; //交通费 Cost2 += evection.Cost2; //住宿费 Cost3 += evection.Cost3; //补贴 Cost4 += evection.Cost4; //市内交通费 Cost5 += evection.Cost5; //的士费 break; } #endregion if (minbegindate > evection.BeginDate) { minbegindate = evection.BeginDate; } if (maxenddate < evection.EndDate) { maxenddate = evection.EndDate; } int cardispatchid = 0; if (int.TryParse(gv_List.DataKeys[row.RowIndex]["Car_DispatchRide_ID"].ToString(), out cardispatchid) && cardispatchid > 0) { Car_DispatchRide dispatch = new Car_DispatchRideBLL(cardispatchid).Model; if (dispatch != null) { Cost11 += dispatch.RoadToll; //过路过桥费 Cost12 += dispatch.FuelFee; //油费 Cost13 += dispatch.ParkingFee; //停车费 Cost13 += dispatch.OtherFee; //其他费 } } selectedevectionids.Add(id); } } if (Cost1 + Cost2 + Cost3 + Cost4 + Cost5 + Cost11 + Cost12 + Cost13 + Cost21 + Cost22 == 0) { MessageBox.Show(this, "对不起,请勾选要报销的差旅行程记录!"); return; } #endregion #region 重设科目金额 FNA_FeeWriteOffBLL bll = new FNA_FeeWriteOffBLL((int)ViewState["WriteOffID"]); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost1ACTitle"), Cost1, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost2ACTitle"), Cost2, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost3ACTitle"), Cost3, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost4ACTitle"), Cost4, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost5ACTitle"), Cost5, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost11ACTitle"), Cost11, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost12ACTitle"), Cost12, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost13ACTitle"), Cost13, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("TrainingCost1ACTitle"), Cost21, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("TrainingCost2ACTitle"), Cost22, flag, minbegindate, maxenddate); #endregion #region 置差旅行程的关联报销单ID foreach (int evectionid in selectedevectionids) { FNA_EvectionRouteBLL evectionbll = new FNA_EvectionRouteBLL(evectionid); if (flag == 1) { evectionbll.Model.WriteOffID = (int)ViewState["WriteOffID"]; } else { evectionbll.Model.WriteOffID = 0; } evectionbll.Update(); } #endregion }
protected void bt_WriteOff_Click(object sender, EventArgs e) { #region 求选中行的差旅费、住宿费、补贴合计 decimal Cost1 = 0, Cost2 = 0, Cost3 = 0, Cost4 = 0, Cost5 = 0; decimal Cost11 = 0, Cost12 = 0, Cost13 = 0; //车辆费用 decimal Cost21 = 0, Cost22 = 0; DateTime minbegindate = DateTime.Parse("2999-1-1"), maxenddate = DateTime.Parse("1900-1-1"); List <int> selectedevectionids = new List <int>(); foreach (GridViewRow row in gv_List.Rows) { CheckBox cbx = (CheckBox)row.FindControl("cbx"); if (cbx != null && cbx.Checked) { int id = (int)gv_List.DataKeys[row.RowIndex][0]; FNA_EvectionRoute evection = new FNA_EvectionRouteBLL(id).Model; #region 根据关联的工作日志的类型,判断是否培训费 //获取关联的日志类型 int journalid = 0, workingclassify = 0; if (int.TryParse(evection["RelateJournal"], out journalid) && journalid > 0) { JN_Journal Joural = new JN_JournalBLL(journalid).Model; if (Joural != null) { workingclassify = Joural.WorkingClassify; } } switch (workingclassify) { case 4: //总部组织的培训,计入总部培训-差旅费 Cost21 += evection.Cost1 + evection.Cost2 + evection.Cost3 + evection.Cost4 + evection.Cost5; break; case 5: //省区组织的培训,计入营业部培训-差旅费 Cost22 += evection.Cost1 + evection.Cost2 + evection.Cost3 + evection.Cost4 + evection.Cost5; break; default: Cost1 += evection.Cost1; //交通费 Cost2 += evection.Cost2; //住宿费 Cost3 += evection.Cost3; //补贴 Cost4 += evection.Cost4; //市内交通费 Cost5 += evection.Cost5; //的士费 break; } #endregion if (minbegindate > evection.BeginDate) { minbegindate = evection.BeginDate; } if (maxenddate < evection.EndDate) { maxenddate = evection.EndDate; } int cardispatchid = 0; if (int.TryParse(gv_List.DataKeys[row.RowIndex]["Car_DispatchRide_ID"].ToString(), out cardispatchid) && cardispatchid > 0) { Car_DispatchRide dispatch = new Car_DispatchRideBLL(cardispatchid).Model; if (dispatch != null) { Cost11 += dispatch.RoadToll; //过路过桥费 Cost12 += dispatch.FuelFee; //油费 Cost13 += dispatch.ParkingFee; //停车费 Cost13 += dispatch.OtherFee; //其他费 } } selectedevectionids.Add(id); } } if (Cost1 + Cost2 + Cost3 + Cost4 + Cost5 + Cost11 + Cost12 + Cost13 + Cost21 + Cost22 == 0) { MessageBox.Show(this, "对不起,请勾选要报销的差旅行程记录!"); return; } #endregion #region 新增费用核销单头 Org_Staff staff = new Org_StaffBLL((int)Session["UserID"]).Model; FNA_FeeWriteOffBLL bll = new FNA_FeeWriteOffBLL(); bll.Model.SheetCode = FNA_FeeWriteOffBLL.GenerateSheetCode(staff.OrganizeCity); //自动产生报销单号 bll.Model.AccountMonth = AC_AccountMonthBLL.GetCurrentMonth(); bll.Model.FeeType = ConfigHelper.GetConfigInt("EvectionFeeType"); //差旅费对应的费用类型 bll.Model.OrganizeCity = staff.OrganizeCity; bll.Model.ApproveFlag = 1; bll.Model.State = 1; bll.Model.InsertStaff = (int)Session["UserID"]; bll.Model["HasFeeApply"] = "N"; //无申请单 bll.Model["IsEvectionWriteOff"] = "Y"; //是差旅报销 #endregion #region 新增费用核销单明细 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost1ACTitle"), Cost1, minbegindate, maxenddate); //交通费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost2ACTitle"), Cost2, minbegindate, maxenddate); //住宿费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost3ACTitle"), Cost3, minbegindate, maxenddate); //补贴 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost4ACTitle"), Cost4, minbegindate, maxenddate); //市内交通费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost5ACTitle"), Cost5, minbegindate, maxenddate); //的士费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost11ACTitle"), Cost11, minbegindate, maxenddate); //车辆费用-路桥费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost12ACTitle"), Cost12, minbegindate, maxenddate); //车辆费用-油费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("EvectionCost13ACTitle"), Cost13, minbegindate, maxenddate); //车辆费用-其他杂费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("TrainingCost1ACTitle"), Cost21, minbegindate, maxenddate); //总部培训费-差旅费 AddWriteOffDetail(bll, ConfigHelper.GetConfigInt("TrainingCost2ACTitle"), Cost22, minbegindate, maxenddate); //营业部培训费-差旅费 #endregion int writeoff = bll.Add(); #region 置差旅行程的关联报销单ID foreach (int evectionid in selectedevectionids) { FNA_EvectionRouteBLL evectionbll = new FNA_EvectionRouteBLL(evectionid); evectionbll.Model.WriteOffID = writeoff; evectionbll.Update(); } #endregion Response.Redirect("FeeWriteoffDetail.aspx?ID=" + writeoff.ToString()); }
private void btn_save_Click(object sender, EventArgs e) { DropDownList invoice = pn_FeeWriteOff.FindControl("FNA_FeeWriteOff_InvoiceClassAB") as DropDownList; if (invoice.SelectedValue == "0" || invoice.SelectedValue == "") { MessageBox.Show(this, "请选择抵货款类型!"); return; } FNA_FeeWriteOffBLL writeoff = new FNA_FeeWriteOffBLL((int)ViewState["ID"]); writeoff.Model["InvoiceClassAB"] = invoice.SelectedValue; if (writeoff.Update() >= 0) MessageBox.Show(this, "调整成功!"); else MessageBox.Show(this, "调整失败!"); }
private void ReComputeCost(int flag) { decimal Cost1 = 0, Cost2 = 0, Cost3 = 0, Cost4 = 0, Cost5 = 0; decimal Cost11 = 0, Cost12 = 0, Cost13 = 0; //车辆费用 decimal Cost21 = 0, Cost22 = 0; //培训差旅费 DateTime minbegindate = DateTime.Parse("2999-1-1"), maxenddate = DateTime.Parse("1900-1-1"); #region 求选中行的差旅费、住宿费、补贴合计 List<int> selectedevectionids = new List<int>(); foreach (GridViewRow row in gv_List.Rows) { CheckBox cbx = (CheckBox)row.FindControl("cbx"); if (cbx != null && cbx.Checked) { int id = (int)gv_List.DataKeys[row.RowIndex][0]; FNA_EvectionRoute evection = new FNA_EvectionRouteBLL(id).Model; #region 根据关联的工作日志的类型,判断是否培训费 //获取关联的日志类型 int journalid = 0, workingclassify = 0; if (int.TryParse(evection["RelateJournal"], out journalid) && journalid > 0) { JN_Journal Joural = new JN_JournalBLL(journalid).Model; if (Joural != null) workingclassify = Joural.WorkingClassify; } switch (workingclassify) { case 4: //总部组织的培训,计入总部培训-差旅费 Cost21 += evection.Cost1 + evection.Cost2 + evection.Cost3 + evection.Cost4 + evection.Cost5; break; case 5: //省区组织的培训,计入营业部培训-差旅费 Cost22 += evection.Cost1 + evection.Cost2 + evection.Cost3 + evection.Cost4 + evection.Cost5; break; default: Cost1 += evection.Cost1; //交通费 Cost2 += evection.Cost2; //住宿费 Cost3 += evection.Cost3; //补贴 Cost4 += evection.Cost4; //市内交通费 Cost5 += evection.Cost5; //的士费 break; } #endregion if (minbegindate > evection.BeginDate) minbegindate = evection.BeginDate; if (maxenddate < evection.EndDate) maxenddate = evection.EndDate; int cardispatchid = 0; if (int.TryParse(gv_List.DataKeys[row.RowIndex]["Car_DispatchRide_ID"].ToString(), out cardispatchid) && cardispatchid > 0) { Car_DispatchRide dispatch = new Car_DispatchRideBLL(cardispatchid).Model; if (dispatch != null) { Cost11 += dispatch.RoadToll; //过路过桥费 Cost12 += dispatch.FuelFee; //油费 Cost13 += dispatch.ParkingFee; //停车费 Cost13 += dispatch.OtherFee; //其他费 } } selectedevectionids.Add(id); } } if (Cost1 + Cost2 + Cost3 + Cost4 + Cost5 + Cost11 + Cost12 + Cost13 + Cost21 + Cost22 == 0) { MessageBox.Show(this, "对不起,请勾选要报销的差旅行程记录!"); return; } #endregion #region 重设科目金额 FNA_FeeWriteOffBLL bll = new FNA_FeeWriteOffBLL((int)ViewState["WriteOffID"]); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost1ACTitle"), Cost1, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost2ACTitle"), Cost2, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost3ACTitle"), Cost3, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost4ACTitle"), Cost4, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost5ACTitle"), Cost5, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost11ACTitle"), Cost11, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost12ACTitle"), Cost12, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("EvectionCost13ACTitle"), Cost13, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("TrainingCost1ACTitle"), Cost21, flag, minbegindate, maxenddate); UpdateDetail(bll, ConfigHelper.GetConfigInt("TrainingCost2ACTitle"), Cost22, flag, minbegindate, maxenddate); #endregion #region 置差旅行程的关联报销单ID foreach (int evectionid in selectedevectionids) { FNA_EvectionRouteBLL evectionbll = new FNA_EvectionRouteBLL(evectionid); if (flag == 1) evectionbll.Model.WriteOffID = (int)ViewState["WriteOffID"]; else evectionbll.Model.WriteOffID = 0; evectionbll.Update(); } #endregion }
private void BindData() { if ((int)ViewState["DetailID"] != 0) { FNA_FeeWriteOffDetail _model = new FNA_FeeWriteOffBLL().GetDetailModel((int)ViewState["DetailID"]); if (_model == null) { MessageBox.ShowAndClose(this, "请先保存核销单后,再完善发票信息!"); return; } FNA_FeeWriteOff writeoff = new FNA_FeeWriteOffBLL(_model.WriteOffID).Model; FNA_FeeApplyDetail _applydetail; if (_model.ApplyDetailID > 0) { _applydetail = new FNA_FeeApplyBLL().GetDetailModel(_model.ApplyDetailID); lbl_applyCode.Text = new FNA_FeeApplyBLL(_applydetail.ApplyID).Model.SheetCode; lb_AvailCost.Text = (_applydetail.AvailCost).ToString("0.00"); ViewState["AvailCost"] = _applydetail.AvailCost; } lbl_Client.Text = _model.Client > 0 ? new CM_ClientBLL(_model.Client).Model.FullName : ""; ViewState["ClientID"] = _model.Client; ViewState["Month"] = _model.BeginMonth; pn_Detail.BindData(_model); if (writeoff.State == 1) { if (tbx_RebateRate.Text == "" || tbx_RebateRate.Text == "0") tbx_RebateRate.Text = "100"; if (tbx_DiscountRate.Text == "") tbx_DiscountRate.Text = "0"; if (tbx_InvoiceCost.Text == "") tbx_InvoiceCost.Text = _model.WriteOffCost.ToString("0.00"); if (tbx_WriteOffCost2.Text == "") tbx_WriteOffCost2.Text = "0.00"; } ComputInvoiceCost(); UploadFile1.RelateID = (int)ViewState["DetailID"]; if (writeoff.State >= 2) { if (bt_ComputeMixRate != null) bt_ComputeMixRate.Visible = false; UploadFile1.CanDelete = false; pn_Detail.SetControlsEnable(false); bt_Save.Visible = false; } if (writeoff.State >= 3) { UploadFile1.CanUpload = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ViewState["WriteOffID"] = Request.QueryString["WriteOffID"] == null ? 0 : int.Parse(Request.QueryString["WriteOffID"]); if ((int)ViewState["WriteOffID"] == 0) { MessageBox.ShowAndClose(this, "参数错误!"); return; } FNA_FeeWriteOff writeoff = new FNA_FeeWriteOffBLL((int)ViewState["WriteOffID"]).Model; if (writeoff == null) { MessageBox.ShowAndClose(this, "参数错误!"); return; } tbx_begin.Text = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-01"); tbx_end.Text = DateTime.Now.ToString("yyyy-MM-dd"); if (writeoff.State > 1) { //已提交 bt_Add.Visible = false; bt_Remove.Visible = false; MCSTabControl1.Visible = false; tb_condition.Visible = false; bt_Find.Visible = false; bt_Save.Visible = false; gv_List.Columns[0].Visible = false; } #region 绑定用户可管辖的管理片区 Org_StaffBLL staff = new Org_StaffBLL(writeoff.InsertStaff); tr_OrganizeCity.DataSource = staff.GetStaffOrganizeCity(); if (tr_OrganizeCity.DataSource.Select("ID = 1").Length > 0) { tr_OrganizeCity.RootValue = "0"; tr_OrganizeCity.SelectValue = "1"; } else { tr_OrganizeCity.RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); tr_OrganizeCity.SelectValue = staff.Model.OrganizeCity.ToString(); } #endregion select_Staff.SelectText = staff.Model.RealName; select_Staff.SelectValue = staff.Model.ID.ToString(); BindGrid(); } #region 注册脚本 //注册修改客户状态按钮script string script = "function OpenJournal(id){\r\n"; script += "var tempid = Math.random() * 10000; \r\n statuschange = window.showModalDialog('" + Page.ResolveClientUrl("~/SubModule/OA/Journal/JournalDetail.aspx") + "?ID='+id+'&tempid='+tempid+'&ViewFramework=false&CloseMode=close', window, 'dialogWidth:800px;DialogHeight=500px;status:yes');}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OpenJournal", script, true); script = "function OpenWorkingPlan(id){\r\n"; script += "var tempid = Math.random() * 10000; \r\n statuschange = window.showModalDialog('" + Page.ResolveClientUrl("~/SubModule/OA/Journal/JournalOnWorkingPlan.aspx") + "?PlanID='+id+'&tempid='+tempid+'&ViewFramework=false&CloseMode=close', window, 'dialogWidth:960px;DialogHeight=600px;status:yes');}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OpenWorkingPlan", script, true); #endregion }
protected void gv_List_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName != "Approved" && e.CommandName != "UnApproved") { BindGrid(); return; } #region 仅查看待我审批的费用申请单 string taskids = ""; if (ddl_State.SelectedValue == "1") { taskids = GetNeedMeApproveTaskIDs(); if (taskids == "") { MessageBox.Show(this, "对不起,没有需要待您审批的费用申请单!"); return; } } #endregion string[] TaskIDs = taskids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); int organizecity = int.Parse(e.CommandArgument.ToString()); string condition = " FNA_FeeWriteOff.State = 2 "; #region 组织明细记录的查询条件 //管理片区及所有下属管理片区 if (organizecity != 1) { Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(organizecity); string orgcitys = orgcity.GetAllChildNodeIDs(); if (orgcitys != "") { orgcitys += ","; } orgcitys += organizecity.ToString(); condition += " AND FNA_FeeWriteOff.OrganizeCity IN (" + orgcitys + ")"; } //会计月条件 condition += " AND FNA_FeeWriteOff.AccountMonth = " + ddl_Month.SelectedValue; #endregion if (e.CommandName == "Approved") { IList <FNA_FeeWriteOff> lists = FNA_FeeWriteOffBLL.GetModelList(condition); foreach (FNA_FeeWriteOff fee in lists) { if (TaskIDs.Contains(fee.ApproveTask.ToString())) { int jobid = EWF_TaskBLL.StaffCanApproveTask(fee.ApproveTask, (int)Session["UserID"]); EWF_Task_JobBLL job = new EWF_Task_JobBLL(jobid); if (job.Model != null) { int decision = job.StaffCanDecide((int)Session["UserID"]); if (decision > 0) { job.Decision(decision, (int)Session["UserID"], 2, "汇总单批量审批通过!"); //2:审批已通过 } } } } BindGrid(); MessageBox.Show(this, "审批成功!"); } else if (e.CommandName == "UnApproved") { IList <FNA_FeeWriteOff> lists = FNA_FeeWriteOffBLL.GetModelList(condition); foreach (FNA_FeeWriteOff fee in lists) { if (TaskIDs.Contains(fee.ApproveTask.ToString())) { int jobid = EWF_TaskBLL.StaffCanApproveTask(fee.ApproveTask, (int)Session["UserID"]); EWF_Task_JobBLL job = new EWF_Task_JobBLL(jobid); if (job.Model != null) { int decision = job.StaffCanDecide((int)Session["UserID"]); if (decision > 0) { job.Decision(decision, (int)Session["UserID"], 3, "汇总单批量未能审批通过!"); //3:审批未通过 } } } } BindGrid(); MessageBox.Show(this, "已成功将选择区域的申请单,设为批复未通过!"); } }
private void BindGrid() { int month = int.Parse(ddl_Month.SelectedValue); int organizecity = int.Parse(tr_OrganizeCity.SelectValue); int level = int.Parse(ddl_Level.SelectedValue); int feetype = int.Parse(ddl_FeeType.SelectedValue); int state = int.Parse(ddl_State.SelectedValue); if (MCSTabControl1.SelectedIndex == 0) { #region 显示汇总单数据源 Dictionary_Data dicFeeType = null; if (feetype > 0) { dicFeeType = DictionaryBLL.GetDicCollections("FNA_FeeType")[feetype.ToString()]; } #region 额外条件 string condition = ""; //费用代垫客户 if (select_Client.SelectValue != "") { condition += " AND FNA_FeeWriteOff.InsteadPayClient=" + select_Client.SelectValue; } //费用代垫员工 if (Select_InsteadPayStaff.SelectValue != "") { condition += " AND MCS_SYS.dbo.UF_Spilt2('MCS_FNA.dbo.FNA_FeeWriteOff',FNA_FeeWriteOff.ExtPropertys,'InsteadPayStaff')=" + Select_InsteadPayStaff.SelectValue; } //核销申请人 if (Select_InsertStaff.SelectValue != "") { condition += " AND FNA_FeeWriteOff.InsertStaff=" + Select_InsertStaff.SelectValue; } #endregion DataTable dtSummary = FNA_FeeWriteOffBLL.GetSummaryTotal(month, organizecity, level, feetype, state, int.Parse(Session["UserID"].ToString()), condition); if (dtSummary.Rows.Count == 0) { gv_List.DataBind(); return; } #region 矩阵化数据表,扩展表数据列 dtSummary.Columns.Add(new DataColumn("ID", Type.GetType("System.Int32"))); if (level < 10) { foreach (DataRow row in dtSummary.Rows) { row["ID"] = row["OrganizeCity"]; } dtSummary = MatrixTable.Matrix(dtSummary, new string[] { "ID", "管理片区名称" }, new string[] { "FeeTypeName", "AccountTitleName" }, "WriteOffCost", true, true); } else { if (level == 10) { //按经销商查看 #region 将经销商的所属管理片区赋至管理片区列 Dictionary <int, string> dicFullOrganizeCityName = new Dictionary <int, string>(); foreach (DataRow row in dtSummary.Rows) { row["ID"] = row["经销商ID"] == DBNull.Value ? 0 : row["经销商ID"]; row["经销商名称"] = row["经销商名称"] == DBNull.Value ? "无" : row["经销商名称"]; if ((int)row["ID"] > 0) { CM_Client c = new CM_ClientBLL((int)row["ID"]).Model; if (c != null) { if (!dicFullOrganizeCityName.ContainsKey(c.OrganizeCity)) { dicFullOrganizeCityName.Add(c.OrganizeCity, TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", c.OrganizeCity)); } row["管理片区名称"] = dicFullOrganizeCityName[c.OrganizeCity]; } } } #endregion dtSummary = MatrixTable.Matrix(dtSummary, new string[] { "ID", "管理片区名称", "经销商名称" }, new string[] { "FeeTypeName", "AccountTitleName" }, "WriteOffCost", true, true); } else if (level == 20) { //按门店查看 #region 将门店的所属管理片区赋至管理片区列 Dictionary <int, string> dicFullOrganizeCityName = new Dictionary <int, string>(); foreach (DataRow row in dtSummary.Rows) { row["ID"] = row["客户ID"] == DBNull.Value ? 0 : row["客户ID"]; row["客户名称"] = row["客户名称"] == DBNull.Value ? "无" : row["客户名称"]; if ((int)row["ID"] > 0) { CM_Client c = new CM_ClientBLL((int)row["ID"]).Model; if (c != null) { if (!dicFullOrganizeCityName.ContainsKey(c.OrganizeCity)) { dicFullOrganizeCityName.Add(c.OrganizeCity, TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", c.OrganizeCity)); } row["管理片区名称"] = dicFullOrganizeCityName[c.OrganizeCity]; } } } #endregion dtSummary = MatrixTable.Matrix(dtSummary, new string[] { "ID", "管理片区名称", "客户名称" }, new string[] { "FeeTypeName", "AccountTitleName" }, "WriteOffCost", true, true); } } dtSummary = MatrixTable.ColumnSummaryTotal(dtSummary, new int[] { 1 }, new string[] { "WriteOffCost" }); #endregion #region 暂不计算分析数据 //dtSummary.Columns["合计"].ColumnName = "费用合计"; //dtSummary.Columns.Add("预计销量", Type.GetType("System.Decimal")); //if (dicFeeType != null && dicFeeType.Description == "BudgetControl" && level < 10) //{ // dtSummary.Columns.Add("预算总额", Type.GetType("System.Decimal")); // dtSummary.Columns.Add("其中扩增额", Type.GetType("System.Decimal")); // dtSummary.Columns.Add("预算余额", Type.GetType("System.Decimal")); //} //if (dicFeeType != null && dicFeeType.Description == "FeeRateControl") // dtSummary.Columns.Add("上月余额", Type.GetType("System.Decimal")); //dtSummary.Columns.Add("费点", Type.GetType("System.String")); //decimal sumTotalVolume = 0, sumTotalBudget = 0, sumExtBudget = 0, sumPreMonthBudgetBalance = 0, sumUsableAmount = 0; //foreach (DataRow row in dtSummary.Rows) //{ // int id = 0; // if (int.TryParse(row[0].ToString(), out id) && id > 0) // { // bool includechild = true; // if (level < 10 && new Addr_OrganizeCityBLL(id).Model.Level < level) includechild = false; // #region 计算费点 // if (level < 10) // row["预计销量"] = SVM_SalesForcastBLL.GetTotalVolume(month, id, includechild); // else if (level == 10 || level == 20) // row["预计销量"] = SVM_SalesForcastBLL.GetTotalVolumeByClient(month, id); // sumTotalVolume += (decimal)row["预计销量"]; // if (dicFeeType != null && dicFeeType.Description == "BudgetControl" && level < 10) // { // row["预算总额"] = (FNA_BudgetBLL.GetSumBudgetAmount(month, id, feetype, includechild) + FNA_BudgetBLL.GetSumBudgetAmount(month, id, 0, includechild)); // sumTotalBudget += (decimal)row["预算总额"]; // row["其中扩增额"] = (FNA_BudgetExtraApplyBLL.GetExtraAmount(month, id, feetype, includechild) + FNA_BudgetExtraApplyBLL.GetExtraAmount(month, id, 0, includechild)); // sumExtBudget += (decimal)row["其中扩增额"]; // row["预算余额"] = (FNA_BudgetBLL.GetUsableAmount(month, id, feetype, includechild) + FNA_BudgetBLL.GetUsableAmount(month, id, 0, includechild)); // sumUsableAmount += (decimal)row["预算余额"]; // } // if (dicFeeType != null && dicFeeType.Description == "FeeRateControl" && level < 10) // { // row["上月余额"] = FNA_BudgetBLL.GetUsableAmount(month - 1, id, feetype, includechild); // sumPreMonthBudgetBalance += (decimal)row["上月余额"]; // if ((decimal)row["预计销量"] != 0) // row["费点"] = (((decimal)row["费用合计"] - (decimal)row["上月余额"]) / (decimal)row["预计销量"]).ToString("0.00%"); // } // else if ((decimal)row["预计销量"] != 0) // row["费点"] = ((decimal)row["费用合计"] / (decimal)row["预计销量"]).ToString("0.00%"); // #endregion // } // #region 求合计行 // if (id == 0) // { // row["预计销量"] = sumTotalVolume.ToString("0.00"); // #region 预算总额及余额 // if (dicFeeType != null && dicFeeType.Description == "BudgetControl" && level < 10) // { // row["预算总额"] = sumTotalBudget.ToString("0.00"); // row["其中扩增额"] = sumExtBudget.ToString("0.00"); // row["预算余额"] = sumUsableAmount.ToString("0.00"); // } // #endregion // #region 费点 // if (sumTotalVolume != 0) // { // if (dicFeeType != null && dicFeeType.Description == "FeeRateControl" && level < 10) // { // row["上月余额"] = sumPreMonthBudgetBalance; // row["费点"] = (((decimal)row["费用合计"] - sumPreMonthBudgetBalance) / sumTotalVolume).ToString("0.##%"); // } // else // row["费点"] = ((decimal)row["费用合计"] / sumTotalVolume).ToString("0.##%"); // } // #endregion // } // #endregion //} #endregion #endregion gv_List.DataSource = dtSummary; gv_List.DataBind(); if (dtSummary.Columns.Count >= 24) { gv_List.Width = new Unit(dtSummary.Columns.Count * 55); } else { gv_List.Width = new Unit(100, UnitType.Percentage); } MatrixTable.GridViewMatric(gv_List); if (level == 20) { //按终端门店显示时,将上下行相同管理片区合并 MatrixTable.GridViewMergSampeValueRow(gv_List, 0); MatrixTable.GridViewMergSampeValueRow(gv_List, 1); } #region 是否可以批量审批 if (state != 1 || level >= 10) { gv_List.Columns[0].ItemStyle.Width = new Unit(1); foreach (GridViewRow row in gv_List.Rows) { row.FindControl("bt_Approved").Visible = false; row.FindControl("bt_UnApproved").Visible = false; } } else { gv_List.Columns[0].ItemStyle.Width = new Unit(68); } #endregion } else { string condition = "1=1"; #region 组织明细记录的查询条件 //管理片区及所有下属管理片区 if (tr_OrganizeCity.SelectValue != "1") { Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue)); string orgcitys = orgcity.GetAllChildNodeIDs(); if (orgcitys != "") { orgcitys += ","; } orgcitys += tr_OrganizeCity.SelectValue; condition += " AND FNA_FeeWriteOff.OrganizeCity IN (" + orgcitys + ")"; } //会计月条件 condition += " AND FNA_FeeWriteOff.AccountMonth = " + ddl_Month.SelectedValue; int accounttile = 0; int.TryParse(tr_AccountTitle.SelectValue, out accounttile); decimal _cost = 0; decimal.TryParse(tbx_WriteOffCost.Text, out _cost); //费用类型 if (ddl_FeeType.SelectedValue != "0" && !(accounttile > 1)) { IList <AC_AccountTitleInFeeType> titles = AC_AccountTitleInFeeTypeBLL.GetModelList("FeeType=" + ddl_FeeType.SelectedValue); string ids = ""; foreach (AC_AccountTitleInFeeType item in titles) { ids += item.AccountTitle + ","; } if (ids.EndsWith(",")) { ids = ids.Substring(0, ids.Length - 1); } condition += " AND FNA_FeeWriteOff.ID IN (SELECT WriteOffID FROM MCS_FNA.dbo.FNA_FeeWriteOffDetail WHERE AccountTitle IN(" + ids + ") AND FNA_FeeWriteOffDetail.WriteOffID=FNA_FeeWriteOff.ID)"; } //费用科目 if (accounttile > 1) { DataTable dt = TreeTableBLL.GetAllChildByNodes("MCS_PUB.dbo.AC_AccountTitle", "ID", "SuperID", accounttile.ToString()); string ids = ""; foreach (DataRow dr in dt.Rows) { ids += dr["ID"].ToString() + ","; } ids += accounttile.ToString(); if (_cost == 0) { condition += " AND FNA_FeeWriteOff.ID IN (SELECT WriteOffID FROM MCS_FNA.dbo.FNA_FeeWriteOffDetail WHERE AccountTitle IN(" + ids + ") AND FNA_FeeWriteOffDetail.WriteOffID=FNA_FeeWriteOff.ID)"; } else { condition += " AND FNA_FeeWriteOff.ID IN (SELECT WriteOffID FROM MCS_FNA.dbo.FNA_FeeWriteOffDetail WHERE AccountTitle IN(" + ids + ") AND (WriteOffCost+AdjustCost)" + ddl_WriteOffCostOP.SelectedValue + " " + _cost.ToString() + " AND FNA_FeeWriteOffDetail.WriteOffID=FNA_FeeWriteOff.ID)"; } } else if (_cost != 0) { //核销金额判断 condition += " AND FNA_FeeWriteOff.ID IN (SELECT WriteOffID FROM MCS_FNA.dbo.FNA_FeeWriteOffDetail WHERE (WriteOffCost+AdjustCost)" + ddl_WriteOffCostOP.SelectedValue + " " + _cost.ToString() + " AND FNA_FeeWriteOffDetail.WriteOffID=FNA_FeeWriteOff.ID)"; } //审批状态 if (ddl_State.SelectedValue == "0") { condition += " AND FNA_FeeWriteOff.State IN (2,3) "; } else if (ddl_State.SelectedValue == "1") { condition += @" AND FNA_FeeWriteOff.State = 2 AND FNA_FeeWriteOff.ApproveTask IN (SELECT EWF_Task_Job.Task FROM MCS_EWF.dbo.EWF_Task_JobDecision INNER JOIN MCS_EWF.dbo.EWF_Task_Job ON EWF_Task_JobDecision.Job = EWF_Task_Job.ID WHERE EWF_Task_JobDecision.RecipientStaff=" + Session["UserID"].ToString() + @" AND EWF_Task_JobDecision.DecisionResult=1 and EWF_Task_Job.Status=3)"; } else if (ddl_State.SelectedValue == "2") { condition += " AND FNA_FeeWriteOff.State = 3 "; } else if (ddl_State.SelectedValue == "3") { AC_AccountMonth m = new AC_AccountMonthBLL(month).Model; condition += @" AND FNA_FeeWriteOff.State IN (2,3) AND FNA_FeeWriteOff.ApproveTask IN (SELECT EWF_Task_Job.Task FROM MCS_EWF.dbo.EWF_Task_JobDecision INNER JOIN MCS_EWF.dbo.EWF_Task_Job ON EWF_Task_JobDecision.Job = EWF_Task_Job.ID WHERE EWF_Task_JobDecision.RecipientStaff=" + Session["UserID"].ToString() + @" AND EWF_Task_JobDecision.DecisionResult IN(2,5,6) AND EWF_Task_JobDecision.DecisionTime BETWEEN DATEADD(month,-1,'" + m.BeginDate.ToString("yyyy-MM-dd") + @"') AND DATEADD(month,3,'" + m.BeginDate.ToString("yyyy-MM-dd") + @"'))"; } //费用代垫客户 if (select_Client.SelectValue != "") { condition += " AND FNA_FeeWriteOff.InsteadPayClient=" + select_Client.SelectValue; } //费用代垫员工 if (Select_InsteadPayStaff.SelectValue != "") { condition += " AND MCS_SYS.dbo.UF_Spilt2('MCS_FNA.dbo.FNA_FeeWriteOff',FNA_FeeWriteOff.ExtPropertys,'InsteadPayStaff')=" + Select_InsteadPayStaff.SelectValue; } //核销申请人 if (Select_InsertStaff.SelectValue != "") { condition += " AND FNA_FeeWriteOff.InsertStaff=" + Select_InsertStaff.SelectValue; } #endregion gv_ListDetail.ConditionString = condition; gv_ListDetail.BindGrid(); } }
private void BindData() { int id = (int)ViewState["ID"]; FNA_FeeWriteOff writeoff = new FNA_FeeWriteOffBLL(id).Model; if (writeoff == null) { Response.Redirect("FeeWriteOffList.aspx"); } if (writeoff["InvoiceClassAB"] == "1") { string Detailid = "0"; FNA_FeeWriteOffDetail _Taxes = new FNA_FeeWriteOffBLL(id).Items.FirstOrDefault(p => p.AccountTitle == 129); if (_Taxes != null) { Detailid = _Taxes.ID.ToString(); } bt_Taxes.OnClientClick = "PopEditTaxes(" + ViewState["ID"].ToString() + "," + Detailid + ")"; } else { bt_Taxes.Visible = false; } ViewState["AccountMonth"] = writeoff.AccountMonth; ViewState["OrganizeCity"] = writeoff.OrganizeCity; ViewState["InsteadPayClient"] = writeoff.InsteadPayClient; ViewState["FeeType"] = writeoff.FeeType; ViewState["HasFeeApply"] = writeoff["HasFeeApply"]; pn_FeeWriteOff.BindData(writeoff); #region 绑定代垫客户的主户头 ViewState["MasterInsteadPayClient"] = 0; if (ViewState["InsteadPayClient"] != null && (int)ViewState["InsteadPayClient"] > 0) { CM_Client client = new CM_ClientBLL((int)ViewState["InsteadPayClient"]).Model; if (client != null && client.ClientType == 2 && client["DIClassify"] == "3") { CM_Client supplier = new CM_ClientBLL(client.Supplier).Model; if (supplier != null && supplier.ClientType == 2 && supplier["DIClassify"] == "1") { HyperLink hy_MasterAccountName = new HyperLink(); hy_MasterAccountName.NavigateUrl = "~/SubModule/CM/DI/DistributorDetail.aspx?ClientID=" + supplier.ID.ToString(); hy_MasterAccountName.Target = "_blank"; hy_MasterAccountName.Text = "关联主户头:" + supplier.FullName; hy_MasterAccountName.ForeColor = System.Drawing.Color.Blue; pn_FeeWriteOff.FindControl("FNA_FeeWriteOff_InsteadPayClient").Parent.Controls.Add(hy_MasterAccountName); ViewState["MasterInsteadPayClient"] = supplier.ID; } } } #endregion UploadFile1.RelateID = (int)ViewState["ID"]; #region 根据审批状态控制页面 if (writeoff.State == 1) { tbx_Remark.Text = writeoff["Remark"]; tbl_Remark.Visible = true; bt_Print.Visible = false; } if (writeoff.State != 1) { //非 未提交 状态 bt_EditWriteOffDetail.Visible = false; bt_AddTitleNoApply.Visible = false; pn_FeeWriteOff.SetPanelEnable("Panel_FNA_FeeWriteOffDetail_1", false); gv_List.Columns[gv_List.Columns.Count - 1].Visible = false; //不可删除 bt_Save.Visible = false; bt_Submit.Visible = false; bt_Delete.Visible = false; writeoff["Remark"] = writeoff["Remark"].Replace("\r", "<br/>"); pn_Remark.BindData(writeoff); pn_Remark.Visible = true; bt_Print.Visible = true; UploadFile1.CanDelete = false; bt_Taxes.Visible = false; //可见调整金额及原因 gv_List.Columns[gv_List.Columns.Count - 6].Visible = true; //扣减备注 gv_List.Columns[gv_List.Columns.Count - 7].Visible = true; //扣减原因 gv_List.Columns[gv_List.Columns.Count - 8].Visible = true; //扣减方式 gv_List.Columns[gv_List.Columns.Count - 9].Visible = true; //扣减金额 gv_List.Columns[gv_List.Columns.Count - 10].Visible = true; //是否逾期 } if (writeoff.State == 2) { //已提交状态 //审批过程中,可以作金额调整 Decision参数为在审批过程中传进来的参数 if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y") { gv_List.Columns[gv_List.Columns.Count - 5].Visible = true; //调整按钮 bt_Taxes.Visible = true; } } if (writeoff.State != 3 && Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1503, "ModifyInfoAB")) { //非已审核状态可以调整 if (pn_FeeWriteOff.FindControl("FNA_FeeWriteOff_InvoiceClassAB") != null) { DropDownList invoice = pn_FeeWriteOff.FindControl("FNA_FeeWriteOff_InvoiceClassAB") as DropDownList; invoice.Enabled = true; Button btn_save = pn_FeeWriteOff.FindControl("btn_saveAB") as Button; btn_save.Visible = true; btn_save.Enabled = true; } } //上传附件 gv_List.Columns[gv_List.Columns.Count - 3].Visible = (writeoff.InsertStaff == (int)Session["UserID"] && writeoff.State == 1) || (writeoff.State < 3 && Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1503, "AddAttachment")); if (writeoff.InsertStaff != (int)Session["UserID"] || writeoff.State >= 3) { UploadFile1.CanUpload = false; UploadFile1.CanDelete = false; gv_List.Columns[gv_List.Columns.Count - 2].Visible = true;//附件 } #endregion SetGridViewColumnAndButton(writeoff["HasFeeApply"] != "N", writeoff["IsEvectionWriteOff"] == "Y", writeoff.State); BindGrid(); }