private void BindData() { JN_Journal m = new JN_JournalBLL((int)ViewState["ID"]).Model; pl_detail.BindData(m); if (m.InsertStaff != (int)Session["UserID"] || m.ApproveFlag == 1 || (DateTime.Today - m.InsertTime.Date).Days > 7) { pl_detail.SetControlsEnable(false); UploadFile1.CanDelete = false; UploadFile1.CanUpload = false; bt_OK.Visible = false; bt_Delete.Visible = false; } if ((DateTime.Today - m.InsertTime.Date).Days > 0) { bt_Delete.Visible = false; //只能删除当日的日志 } #region 展示附件 UploadFile1.RelateID = (int)ViewState["ID"]; UploadFile1.RelateType = 90; UploadFile1.BindGrid(); #endregion lb_CommentCounts.Text = JN_JournalCommentBLL.GetModelList("JournalID=" + ViewState["ID"].ToString()).Count.ToString(); }
protected void bt_Delete_Click(object sender, EventArgs e) { if (ViewState["ID"] != null) { JN_JournalBLL bll = new JN_JournalBLL((int)ViewState["ID"]); bll.Delete(); MessageBox.ShowAndRedirect(this, "日志删除成功!", "JournalCalendar.aspx"); } }
protected void bt_Delete_Click(object sender, EventArgs e) { if (ViewState["ID"] != null) { JN_JournalBLL bll = new JN_JournalBLL((int)ViewState["ID"]); bll.Delete(); MessageBox.ShowAndRedirect(this, "日志删除成功!", "JournalCalendar.aspx"); } }
protected void bt_Delete_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { JN_JournalBLL bll = new JN_JournalBLL((int)ViewState["ID"]); bll.Delete(); MessageBox.ShowAndClose(this, "日志删除成功!"); } }
protected void bt_Delete_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { JN_JournalBLL bll = new JN_JournalBLL((int)ViewState["ID"]); bll.Delete(); MessageBox.ShowAndClose(this, "日志删除成功!"); } }
protected void bt_OK_Click(object sender, EventArgs e) { JN_JournalBLL _bll = null; if (ViewState["ID"] == null) { _bll = new JN_JournalBLL(); } else { _bll = new JN_JournalBLL((int)ViewState["ID"]); } pl_detail.GetData(_bll.Model); _bll.Model.Title = "拜访医院:" + select_RelateClient.SelectText; _bll.Model.EndTime = _bll.Model.BeginTime; #region 判断必填项 if (_bll.Model["SynergeticStaff"] == "") { MessageBox.Show(this, "辅导与代教员工必填!"); return; } #endregion if (ViewState["ID"] == null) { _bll.Model.Staff = (int)Session["UserID"]; _bll.Model.OrganizeCity = new Org_StaffBLL((int)Session["UserID"]).Model.OrganizeCity; _bll.Model.JournalType = 4; _bll.Model.WorkingClassify = 1; _bll.Model.ApproveFlag = 2; _bll.Model["HasSynergeticStaff"] = "1"; _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Model["IPAddress"] = Request.UserHostAddress; ViewState["ID"] = _bll.Add(); } else { _bll.Model.UpdateStaff = (int)Session["UserID"]; _bll.Update(); } if (sender != null) { MessageBox.ShowAndRedirect(this, "日志保存成功!", "JournalList_FDDJ.aspx");//.aspx?ID=" + ViewState["ID"].ToString()); } }
protected void bt_OK_Click(object sender, EventArgs e) { JN_JournalBLL _bll = null; if (ViewState["ID"] == null) { _bll = new JN_JournalBLL(); } else { _bll = new JN_JournalBLL((int)ViewState["ID"]); } pl_detail.GetData(_bll.Model); _bll.Model.Title = "拜访医院:"+select_RelateClient.SelectText; _bll.Model.EndTime = _bll.Model.BeginTime; #region 判断必填项 if (_bll.Model["SynergeticStaff"] == "") { MessageBox.Show(this, "辅导与代教员工必填!"); return; } #endregion if (ViewState["ID"] == null) { _bll.Model.Staff = (int)Session["UserID"]; _bll.Model.OrganizeCity = new Org_StaffBLL((int)Session["UserID"]).Model.OrganizeCity; _bll.Model.JournalType = 4; _bll.Model.WorkingClassify = 1; _bll.Model.ApproveFlag = 2; _bll.Model["HasSynergeticStaff"] = "1"; _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Model["IPAddress"] = Request.UserHostAddress; ViewState["ID"] = _bll.Add(); } else { _bll.Model.UpdateStaff = (int)Session["UserID"]; _bll.Update(); } if (sender != null) MessageBox.ShowAndRedirect(this, "日志保存成功!", "JournalList_FDDJ.aspx");//.aspx?ID=" + ViewState["ID"].ToString()); }
protected void bt_ToEvectionRoute_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { JN_Journal j = new JN_JournalBLL((int)ViewState["ID"]).Model; IList <FNA_EvectionRoute> evections = FNA_EvectionRouteBLL.GetModelList("RelateStaff=" + j.Staff + " AND MCS_SYS.dbo.UF_Spilt2('MCS_FNA.dbo.FNA_EvectionRoute',ExtPropertys,'RelateJournal')='" + j.ID.ToString() + "'"); if (evections.Count > 0) { //系统中已有关联于该工作日志的差旅行程 Response.Redirect("~/SubModule/FNA/FeeWriteOff/Pop_EvectionRouteDetail.aspx?ID=" + evections[0].ID.ToString()); } else { if (j.InsertStaff == (int)Session["UserID"]) { FNA_EvectionRouteBLL evectionbll = new FNA_EvectionRouteBLL(); evectionbll.Model.RelateStaff = j.Staff; evectionbll.Model.BeginDate = j.BeginTime; evectionbll.Model.EndDate = j.EndTime; evectionbll.Model.EvectionLine = j["StartPoint"] + "-" + j["EndPoint"]; evectionbll.Model["HotelName"] = j["HotelName"]; evectionbll.Model["HotelTele"] = j["HotelPhone"]; evectionbll.Model["RelateJournal"] = j.ID.ToString(); evectionbll.Model.InsertStaff = j.InsertStaff; evectionbll.Model.ApproveFlag = 2; int id = evectionbll.Add(); Response.Redirect("~/SubModule/FNA/FeeWriteOff/Pop_EvectionRouteDetail.aspx?ID=" + id.ToString()); } else { MessageBox.Show(this, "对不起,只有日志填报人才可填报该日志的差旅行程信息!"); return; } } } }
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()); }
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) { if (ViewState["Staff"] != null && (int)ViewState["Staff"] > 0) { e.Cell.HorizontalAlign = HorizontalAlign.Left; if (e.Day.Date <= DateTime.Today && MCSTabControl1.SelectedIndex == 0) { ImageButton ibt = new ImageButton(); ibt.ImageUrl = "~/Images/gif/gif-0489.gif"; ibt.BorderWidth = new Unit(0); ibt.ToolTip = "新增工作日志"; ibt.OnClientClick = "javascript:NewJournal('" + e.Day.Date.DayOfYear.ToString() + "')"; ibt.Click += new ImageClickEventHandler(ibt_Click); e.Cell.Controls.Add(ibt); } #region 获取该员工当天工作日志 if (cbx_Journal.Checked) { IList <JN_Journal> journallists = JN_JournalBLL.GetModelList("'" + e.Day.Date.ToString("yyyy-MM-dd") + "' BETWEEN Convert(varchar(10),BeginTime,120) And EndTime AND Staff=" + ViewState["Staff"].ToString()); if (journallists.Count > 0) { BulletedList bt = new BulletedList(); foreach (JN_Journal j in journallists) { ListItem item = new ListItem(); item.Text = ""; if (j.JournalType == 1) { //日报 if (j.BeginTime.Hour != 0 && j.EndTime.Hour != 0) { item.Text += j.BeginTime.ToString("HH:mm") + "~" + j.EndTime.ToString("HH:mm") + " "; } if (j.WorkingClassify != 0) { item.Text += DictionaryBLL.GetDicCollections("OA_WorkingClassify")[j.WorkingClassify.ToString()].Name + " "; switch (j.WorkingClassify) { case 1: //门店拜访 if (j.RelateClient != 0) { //门店拜访 CM_Client client = new CM_ClientBLL(j.RelateClient).Model; if (client != null) { item.Text += client.ShortName + " "; } if (j["VisitClientPurpose"] != "" && j["VisitClientPurpose"] != "0") { item.Text += DictionaryBLL.GetDicCollections("OA_JN_VisitClientPurpose")[j["VisitClientPurpose"]].Name + " "; } } break; case 2: //协同拜访 if (j.RelateStaff != 0) { Org_Staff staff = new Org_StaffBLL(j.RelateStaff).Model; if (staff != null) { item.Text += staff.RealName; } } break; default: item.Text += j.Title; break; } } else { item.Text += j.Title; } } else { //周报、月报 item.Text += DictionaryBLL.GetDicCollections("OA_JournalType")[j.JournalType.ToString()].Name + " "; item.Text += j.Title; } item.Value = "javascript:OpenJournal(" + j.ID.ToString() + ")"; bt.Items.Add(item); } bt.DisplayMode = BulletedListDisplayMode.HyperLink; bt.BulletImageUrl = "~/Images/gif/gif-0162.gif"; bt.BulletStyle = BulletStyle.CustomImage; bt.CssClass = "calaitem"; e.Cell.Controls.Add(bt); } } #endregion #region 获取访员工当天的工作计划 if (cbx_Plan.Checked) { if (ViewState["PlanDetails"] == null || ((IList <JN_WorkingPlanDetail>)ViewState["PlanDetails"]).Where (p => (p.BeginTime.Date <= e.Day.Date && p.EndTime.Date >= e.Day.Date)).Count() == 0) { IList <JN_WorkingPlan> plans = JN_WorkingPlanBLL.GetModelList("'" + e.Day.Date.ToString("yyyy-MM-dd") + "' BETWEEN BeginDate AND EndDate AND Staff=" + ViewState["Staff"].ToString()); if (plans.Count > 0) { IList <JN_WorkingPlanDetail> plandetails = new JN_WorkingPlanBLL(plans[0].ID).Items; ViewState["PlanDetails"] = plandetails; } else { ViewState["PlanDetails"] = null; } } if (ViewState["PlanDetails"] != null) { IList <JN_WorkingPlanDetail> plandetails = (IList <JN_WorkingPlanDetail>)ViewState["PlanDetails"]; BulletedList bt = new BulletedList(); foreach (JN_WorkingPlanDetail plan in plandetails.Where(p => (p.BeginTime.Date <= e.Day.Date && p.EndTime.Date >= e.Day.Date))) { ListItem item = new ListItem(); item.Text = ""; if (plan.WorkingClassify == 0) { continue; } item.Text += DictionaryBLL.GetDicCollections("OA_WorkingClassify")[plan.WorkingClassify.ToString()].Name + " "; switch (plan.WorkingClassify) { case 1: //门店拜访 if (plan.RelateClient != 0) { //门店拜访 CM_Client client = new CM_ClientBLL(plan.RelateClient).Model; if (client != null) { item.Text += client.ShortName + " "; } } break; case 2: //协同拜访 if (plan.RelateStaff != 0) { Org_Staff staff = new Org_StaffBLL(plan.RelateStaff).Model; if (staff != null) { item.Text += staff.RealName + " "; } } break; default: item.Text += plan.Description + " "; break; } if (plan.OfficialCity > 1) { item.Text += TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", plan.OfficialCity).Replace("->", ""); } bt.Items.Add(item); } bt.DisplayMode = BulletedListDisplayMode.Text; bt.BulletImageUrl = "~/Images/gif/gif-0163.gif"; bt.BulletStyle = BulletStyle.CustomImage; bt.CssClass = "calaitem"; e.Cell.Controls.Add(bt); } } #endregion } }
protected void bt_ToEvectionRoute_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { JN_Journal j = new JN_JournalBLL((int)ViewState["ID"]).Model; IList<FNA_EvectionRoute> evections = FNA_EvectionRouteBLL.GetModelList("RelateStaff=" + j.Staff + " AND MCS_SYS.dbo.UF_Spilt2('MCS_FNA.dbo.FNA_EvectionRoute',ExtPropertys,'RelateJournal')='" + j.ID.ToString() + "'"); if (evections.Count > 0) { //系统中已有关联于该工作日志的差旅行程 Response.Redirect("~/SubModule/FNA/FeeWriteOff/Pop_EvectionRouteDetail.aspx?ID=" + evections[0].ID.ToString()); } else { if (j.InsertStaff == (int)Session["UserID"]) { FNA_EvectionRouteBLL evectionbll = new FNA_EvectionRouteBLL(); evectionbll.Model.RelateStaff = j.Staff; evectionbll.Model.BeginDate = j.BeginTime; evectionbll.Model.EndDate = j.EndTime; evectionbll.Model.EvectionLine = j["StartPoint"] + "-" + j["EndPoint"]; evectionbll.Model["HotelName"] = j["HotelName"]; evectionbll.Model["HotelTele"] = j["HotelPhone"]; evectionbll.Model["RelateJournal"] = j.ID.ToString(); evectionbll.Model.InsertStaff = j.InsertStaff; evectionbll.Model.ApproveFlag = 2; int id = evectionbll.Add(); Response.Redirect("~/SubModule/FNA/FeeWriteOff/Pop_EvectionRouteDetail.aspx?ID=" + id.ToString()); } else { MessageBox.Show(this, "对不起,只有日志填报人才可填报该日志的差旅行程信息!"); return; } } } }
protected void bt_OK_Click(object sender, EventArgs e) { if ((DateTime.Today - Convert.ToDateTime(tbx_begindate.Text)).Days > 7) { MessageBox.Show(this, "不能填写一周之前的日志!"); return; } JN_JournalBLL _bll = null; if ((int)ViewState["ID"] == 0) { _bll = new JN_JournalBLL(); } else { _bll = new JN_JournalBLL((int)ViewState["ID"]); } #region 绑定界面控件 _bll.Model.Staff = int.Parse(select_Staff.SelectValue); _bll.Model.OrganizeCity = new Org_StaffBLL(int.Parse(select_Staff.SelectValue)).Model.OrganizeCity; _bll.Model.BeginTime = DateTime.Parse(tbx_begindate.Text + " " + ddl_BeginHour.SelectedValue + ":" + ddl_BeginMinute.SelectedValue); _bll.Model.EndTime = DateTime.Parse(tbx_begindate.Text + " " + ddl_EndHour.SelectedValue + ":" + ddl_EndMinute.SelectedValue); _bll.Model.JournalType = int.Parse(ddl_JournalType.SelectedValue); _bll.Model.WorkingClassify = int.Parse(ddl_WorkingClassify.SelectedValue); pl_detail.GetData(_bll.Model); #endregion #region 判断必填项 if (_bll.Model.JournalType == 0) { MessageBox.Show(this, "日志类型必填!"); return; } if (_bll.Model.WorkingClassify == 0) { MessageBox.Show(this, "工作类别必填!"); return; } if (_bll.Model.OrganizeCity == 0) { MessageBox.Show(this, "所属的管理片区必填!"); return; } //if ((_bll.Model.WorkingClassify == 1 || _bll.Model.WorkingClassify == 7) && (_bll.Model["StartPoint"] == "" || _bll.Model["EndPoint"] == "")) //{ // MessageBox.Show(this, "【出差始发地】、【出差目的地】必填!"); // return; //} #endregion if ((int)ViewState["ID"] == 0) { _bll.Model.ApproveFlag = 2; _bll.Model.InsertStaff = (int)Session["UserID"]; ViewState["ID"] = _bll.Add(); } else { _bll.Model.UpdateStaff = (int)Session["UserID"]; _bll.Update(); } // MessageBox.ShowAndClose(this, "日志保存成功!"); Response.Redirect("JournalDetail.aspx?ID=" + ViewState["ID"].ToString()); }
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()); }
protected void bt_OK_Click(object sender, EventArgs e) { if ((DateTime.Today - Convert.ToDateTime(tbx_begindate.Text)).Days > 7) { MessageBox.Show(this, "不能填写一周之前的日志!"); return; } JN_JournalBLL _bll = null; if ((int)ViewState["ID"] == 0) { _bll = new JN_JournalBLL(); } else { _bll = new JN_JournalBLL((int)ViewState["ID"]); } #region 绑定界面控件 _bll.Model.Staff = int.Parse(select_Staff.SelectValue); _bll.Model.OrganizeCity = new Org_StaffBLL(int.Parse(select_Staff.SelectValue)).Model.OrganizeCity; _bll.Model.BeginTime = DateTime.Parse(tbx_begindate.Text + " " + ddl_BeginHour.SelectedValue + ":" + ddl_BeginMinute.SelectedValue); _bll.Model.EndTime = DateTime.Parse(tbx_begindate.Text + " " + ddl_EndHour.SelectedValue + ":" + ddl_EndMinute.SelectedValue); _bll.Model.JournalType = int.Parse(ddl_JournalType.SelectedValue); _bll.Model.WorkingClassify = int.Parse(ddl_WorkingClassify.SelectedValue); pl_detail.GetData(_bll.Model); #endregion #region 判断必填项 if (_bll.Model.JournalType == 0) { MessageBox.Show(this, "日志类型必填!"); return; } if (_bll.Model.WorkingClassify == 0) { MessageBox.Show(this, "工作类别必填!"); return; } if (_bll.Model.OrganizeCity == 0) { MessageBox.Show(this, "所属的管理片区必填!"); return; } //if ((_bll.Model.WorkingClassify == 1 || _bll.Model.WorkingClassify == 7) && (_bll.Model["StartPoint"] == "" || _bll.Model["EndPoint"] == "")) //{ // MessageBox.Show(this, "【出差始发地】、【出差目的地】必填!"); // return; //} #endregion if ((int)ViewState["ID"] == 0) { _bll.Model.ApproveFlag = 2; _bll.Model.InsertStaff = (int)Session["UserID"]; ViewState["ID"] = _bll.Add(); } else { _bll.Model.UpdateStaff = (int)Session["UserID"]; _bll.Update(); } // MessageBox.ShowAndClose(this, "日志保存成功!"); Response.Redirect("JournalDetail.aspx?ID=" + ViewState["ID"].ToString()); }
private void BindData() { JN_Journal m = new JN_JournalBLL((int)ViewState["ID"]).Model; Org_StaffBLL staff = new Org_StaffBLL(m.Staff, true); select_Staff.SelectValue = m.Staff.ToString(); select_Staff.SelectText = staff.Model.RealName; select_Staff.Enabled = false; Org_PositionBLL position = new Org_PositionBLL(staff.Model.Position); lbl_Position.Text = position.Model.Name; ddl_JournalType.SelectedValue = m.JournalType.ToString(); ddl_JournalType_SelectedIndexChanged(null, null); ddl_JournalType.Enabled = false; tbx_begindate.Text = m.BeginTime.ToString("yyyy-MM-dd"); tbx_enddate.Text = m.EndTime.ToString("yyyy-MM-dd"); try { ddl_BeginHour.SelectedValue = m.BeginTime.Hour.ToString("d2"); ddl_BeginMinute.SelectedValue = m.BeginTime.Minute.ToString("d2"); ddl_EndHour.SelectedValue = m.EndTime.Hour.ToString("d2"); ddl_EndMinute.SelectedValue = m.EndTime.Minute.ToString("d2"); } catch { } ddl_WorkingClassify.SelectedValue = m.WorkingClassify.ToString(); ddl_WorkingClassify_SelectedIndexChanged(null, null); ddl_WorkingClassify.Enabled = false; pl_detail.BindData(m); rbl_HasSynergeticStaff_SelectedIndexChanged(null, null); select_RelateClient_SelectChange(null, null); if (ddl_RelateLinkMan.Items.FindByValue(m.RelateLinkMan.ToString()) != null) ddl_RelateLinkMan.SelectedValue = m.RelateLinkMan.ToString(); if (m.WorkingClassify == 1 && m.RelateLinkMan > 0) { //客户拜访 bt_AddNewClient.OnClientClick = "javascript:OpenClientInput(" + m.ID.ToString() + "," + m.RelateLinkMan + ",0)"; bt_AddNewClient.Enabled = true; } else if (m.WorkingClassify == 3 && !string.IsNullOrEmpty(m["RelateActivity"])) { //活动举办 bt_AddNewClient.OnClientClick = "javascript:OpenClientInput(" + m.ID.ToString() + ",0," + m["RelateActivity"] + ")"; bt_AddNewClient.Enabled = true; } else { bt_AddNewClient.Enabled = false; } #region 显示日志填报时的IP地址 TextBox tbx_IPAddress = (TextBox)pl_detail.FindControl("JN_Journal_IPAddress"); if (m["IPAddress"] != "" && m["IPLocation"] == "") { TextBox tbx_IPLocation = (TextBox)pl_detail.FindControl("JN_Journal_IPLocation"); userAddress = Const_IPLocationBLL.FindByIP(Request.UserHostAddress); if (tbx_IPLocation != null) tbx_IPLocation.Text = userAddress != null ? userAddress.Location : ""; } #endregion Label lbl_InsertStaff = (Label)pl_detail.FindControl("JN_Journal_InsertStaff"); if (lbl_InsertStaff != null) { Org_StaffBLL _staff = new Org_StaffBLL(m.InsertStaff, true); Org_PositionBLL _position = new Org_PositionBLL(_staff.Model.Position); lbl_InsertStaff.Text = lbl_InsertStaff.Text + "(职位:" + _position.Model.Name + ")"; } if (m.InsertStaff != (int)Session["UserID"] || m.ApproveFlag == 1 || (DateTime.Today - m.InsertTime.Date).Days > 7) { ddl_JournalType.Enabled = false; tbx_begindate.Enabled = false; ddl_WorkingClassify.Enabled = false; ddl_BeginHour.Enabled = false; ddl_BeginMinute.Enabled = false; ddl_EndHour.Enabled = false; ddl_EndMinute.Enabled = false; pl_detail.SetControlsEnable(false); TextBox tbx_remark = pl_detail.FindControl("JN_Journal_Remark") != null ? (TextBox)pl_detail.FindControl("JN_Journal_Remark") : null; if (tbx_remark != null) { tbx_remark.Enabled = true; tbx_remark.ReadOnly = true; } UploadFile1.CanDelete = false; UploadFile1.CanUpload = false; bt_OK.Visible = false; bt_Delete.Visible = false; } if ((DateTime.Today - m.InsertTime.Date).Days > 0) bt_Delete.Visible = false; //只能删除当日填写的日志 #region 展示附件 UploadFile1.RelateID = (int)ViewState["ID"]; UploadFile1.RelateType = 90; UploadFile1.BindGrid(); #endregion int commentcounts = JN_JournalCommentBLL.GetModelList("JournalID=" + ViewState["ID"].ToString()).Count; lb_CommentCounts.Text = commentcounts.ToString(); if (commentcounts > 0) { table_comment.Visible = true; BindGridList(); btn_LookComment.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 }
private void BindData() { JN_Journal m = new JN_JournalBLL((int)ViewState["ID"]).Model; Org_StaffBLL staff = new Org_StaffBLL(m.Staff, true); select_Staff.SelectValue = m.Staff.ToString(); select_Staff.SelectText = staff.Model.RealName; select_Staff.Enabled = false; Org_PositionBLL position = new Org_PositionBLL(staff.Model.Position); lbl_Position.Text = position.Model.Name; ddl_JournalType.SelectedValue = m.JournalType.ToString(); ddl_JournalType_SelectedIndexChanged(null, null); ddl_JournalType.Enabled = false; tbx_begindate.Text = m.BeginTime.ToString("yyyy-MM-dd"); tbx_enddate.Text = m.EndTime.ToString("yyyy-MM-dd"); try { ddl_BeginHour.SelectedValue = m.BeginTime.Hour.ToString("d2"); ddl_BeginMinute.SelectedValue = m.BeginTime.Minute.ToString("d2"); ddl_EndHour.SelectedValue = m.EndTime.Hour.ToString("d2"); ddl_EndMinute.SelectedValue = m.EndTime.Minute.ToString("d2"); } catch { } ddl_WorkingClassify.SelectedValue = m.WorkingClassify.ToString(); ddl_WorkingClassify_SelectedIndexChanged(null, null); ddl_WorkingClassify.Enabled = false; pl_detail.BindData(m); rbl_HasSynergeticStaff_SelectedIndexChanged(null, null); select_RelateClient_SelectChange(null, null); if (ddl_RelateLinkMan.Items.FindByValue(m.RelateLinkMan.ToString()) != null) { ddl_RelateLinkMan.SelectedValue = m.RelateLinkMan.ToString(); } if (m.WorkingClassify == 1 && m.RelateLinkMan > 0) { //客户拜访 bt_AddNewClient.OnClientClick = "javascript:OpenClientInput(" + m.ID.ToString() + "," + m.RelateLinkMan + ",0)"; bt_AddNewClient.Enabled = true; } else if (m.WorkingClassify == 3 && !string.IsNullOrEmpty(m["RelateActivity"])) { //活动举办 bt_AddNewClient.OnClientClick = "javascript:OpenClientInput(" + m.ID.ToString() + ",0," + m["RelateActivity"] + ")"; bt_AddNewClient.Enabled = true; } else { bt_AddNewClient.Enabled = false; } #region 显示日志填报时的IP地址 TextBox tbx_IPAddress = (TextBox)pl_detail.FindControl("JN_Journal_IPAddress"); if (m["IPAddress"] != "" && m["IPLocation"] == "") { TextBox tbx_IPLocation = (TextBox)pl_detail.FindControl("JN_Journal_IPLocation"); userAddress = Const_IPLocationBLL.FindByIP(Request.UserHostAddress); if (tbx_IPLocation != null) { tbx_IPLocation.Text = userAddress != null ? userAddress.Location : ""; } } #endregion Label lbl_InsertStaff = (Label)pl_detail.FindControl("JN_Journal_InsertStaff"); if (lbl_InsertStaff != null) { Org_StaffBLL _staff = new Org_StaffBLL(m.InsertStaff, true); Org_PositionBLL _position = new Org_PositionBLL(_staff.Model.Position); lbl_InsertStaff.Text = lbl_InsertStaff.Text + "(职位:" + _position.Model.Name + ")"; } if (m.InsertStaff != (int)Session["UserID"] || m.ApproveFlag == 1 || (DateTime.Today - m.InsertTime.Date).Days > 7) { ddl_JournalType.Enabled = false; tbx_begindate.Enabled = false; ddl_WorkingClassify.Enabled = false; ddl_BeginHour.Enabled = false; ddl_BeginMinute.Enabled = false; ddl_EndHour.Enabled = false; ddl_EndMinute.Enabled = false; pl_detail.SetControlsEnable(false); TextBox tbx_remark = pl_detail.FindControl("JN_Journal_Remark") != null ? (TextBox)pl_detail.FindControl("JN_Journal_Remark") : null; if (tbx_remark != null) { tbx_remark.Enabled = true; tbx_remark.ReadOnly = true; } UploadFile1.CanDelete = false; UploadFile1.CanUpload = false; bt_OK.Visible = false; bt_Delete.Visible = false; } if ((DateTime.Today - m.InsertTime.Date).Days > 0) { bt_Delete.Visible = false; //只能删除当日填写的日志 } #region 展示附件 UploadFile1.RelateID = (int)ViewState["ID"]; UploadFile1.RelateType = 90; UploadFile1.BindGrid(); #endregion int commentcounts = JN_JournalCommentBLL.GetModelList("JournalID=" + ViewState["ID"].ToString()).Count; lb_CommentCounts.Text = commentcounts.ToString(); if (commentcounts > 0) { table_comment.Visible = true; BindGridList(); btn_LookComment.Visible = false; } }
private DataTable LoadWorkingPlanDetail(int planid) { JN_WorkingPlanBLL bll = new JN_WorkingPlanBLL(planid); DataTable dt = GenareateDataTable(bll.Model.BeginDate, bll.Model.EndDate); #region 载入原工作计划 foreach (JN_WorkingPlanDetail detail in bll.Items.OrderBy(p => p.WorkingClassify)) { DataRow[] rows = dt.Select("WorkingClassify = " + detail.WorkingClassify.ToString() + " AND Description = '" + detail.Description + "' " + " AND RelateStaff = " + detail.RelateStaff.ToString() + " AND RelateClient = " + detail.RelateClient.ToString() + " AND OfficialCity = " + detail.OfficialCity.ToString()); if (rows.Length > 0) { DateTime date = detail.BeginTime; while (date <= detail.EndTime) { rows[0]["P" + date.ToString("MMdd")] = true; date = date.AddDays(1); } } else { DataRow dr = dt.NewRow(); dr["WorkingClassify"] = detail.WorkingClassify; dr["WorkingClassifyName"] = DictionaryBLL.GetDicCollections("OA_WorkingClassify")[detail.WorkingClassify.ToString()].Name; dr["Description"] = detail.Description; dr["RelateClient"] = detail.RelateClient; if (detail.RelateClient > 0) { dr["RelateClientName"] = new CM_ClientBLL(detail.RelateClient).Model.FullName; } dr["RelateStaff"] = detail.RelateStaff; if (detail.RelateStaff > 0) { dr["RelateStaffName"] = new Org_StaffBLL(detail.RelateStaff).Model.RealName; } dr["OfficialCity"] = detail.OfficialCity; if (detail.OfficialCity > 0) { dr["OfficialCityName"] = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", detail.OfficialCity).Replace("->", " "); } DateTime date = detail.BeginTime; while (date <= detail.EndTime) { dr["P" + date.ToString("MMdd")] = true; date = date.AddDays(1); } if (detail["Cost1"] != "") { dr["Cost1"] = decimal.Parse(detail["Cost1"]); } else { dr["Cost1"] = 0; } if (detail["Cost2"] != "") { dr["Cost2"] = decimal.Parse(detail["Cost2"]); } else { dr["Cost2"] = 0; } dt.Rows.Add(dr); } } #endregion #region 加载数据库中已填报的日志 string con = "Staff = " + bll.Model.Staff.ToString() + " AND BeginTime BETWEEN '" + bll.Model.BeginDate.ToString("yyyy-MM-dd") + "' AND '" + bll.Model.EndDate.ToString("yyyy-MM-dd 23:59:59") + "' " + " AND JournalType = 1"; IList <JN_Journal> Journals = JN_JournalBLL.GetModelList(con); foreach (JN_Journal journal in Journals.OrderBy(p => p.WorkingClassify)) { DataRow[] rows = dt.Select("WorkingClassify = " + journal.WorkingClassify.ToString() + " AND Description = '" + journal.Title + "' " + " AND RelateStaff = " + (journal.WorkingClassify == 2 ? journal.RelateStaff.ToString() : "0") + " AND RelateClient = " + (journal.WorkingClassify == 1 ? journal.RelateClient.ToString() : "0") + " AND OfficialCity = " + journal.OfficialCity.ToString()); if (rows.Length == 0) { rows = dt.Select("WorkingClassify = " + journal.WorkingClassify.ToString() + " AND Description = '' " + " AND RelateStaff = " + (journal.WorkingClassify == 2 ? journal.RelateStaff.ToString() : "0") + " AND RelateClient = " + (journal.WorkingClassify == 1 ? journal.RelateClient.ToString() : "0") + " AND OfficialCity = " + journal.OfficialCity.ToString()); } if (rows.Length > 0) { rows[0]["J" + journal.BeginTime.ToString("MMdd")] = true; rows[0]["JID" + journal.BeginTime.ToString("MMdd")] = journal.ID; DateTime date = journal.BeginTime; while (date <= journal.EndTime) { rows[0]["J" + date.ToString("MMdd")] = true; rows[0]["JID" + date.ToString("MMdd")] = journal.ID; date = date.AddDays(1); } } else { #region 增加无计划的日志 DataRow dr = dt.NewRow(); dr["WorkingClassify"] = journal.WorkingClassify; if (journal.WorkingClassify > 0) { dr["WorkingClassifyName"] = DictionaryBLL.GetDicCollections("OA_WorkingClassify")[journal.WorkingClassify.ToString()].Name; } dr["Description"] = journal.Title; dr["RelateClient"] = journal.RelateClient; if (journal.RelateClient > 0) { dr["RelateClientName"] = new CM_ClientBLL(journal.RelateClient).Model.FullName; } dr["RelateStaff"] = journal.RelateStaff; if (journal.RelateStaff > 0) { dr["RelateStaffName"] = new Org_StaffBLL(journal.RelateStaff).Model.RealName; } dr["OfficialCity"] = journal.OfficialCity; if (journal.OfficialCity > 0) { dr["OfficialCityName"] = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", journal.OfficialCity).Replace("->", " "); } DateTime date = journal.BeginTime; while (date <= journal.EndTime) { dr["J" + date.ToString("MMdd")] = true; dr["JID" + date.ToString("MMdd")] = journal.ID; date = date.AddDays(1); } dt.Rows.Add(dr); #endregion } } #endregion return(dt); }
protected void bt_Save_Click(object sender, EventArgs e) { if (ViewState["WorkingPlanData"] != null) { DataTable dt = (DataTable)ViewState["WorkingPlanData"]; DateTime begindate = (DateTime)ViewState["BeginDate"]; DateTime enddate = (DateTime)ViewState["EndDate"]; #region 将界面中已选择的日志放入IList中 IList <JN_Journal> NewJournals = new List <JN_Journal>(); for (int i = 0; i < dt.Rows.Count; i++) { JN_Journal jn = null; DateTime day = begindate; while (day <= enddate) { if ((bool)dt.Rows[i]["J" + day.ToString("MMdd")]) { #region 新增日志 if (jn == null) { jn = new JN_Journal(); jn.Title = (string)dt.Rows[i]["Description"]; jn.OrganizeCity = new Org_StaffBLL((int)ViewState["PlanStaff"]).Model.OrganizeCity; jn.JournalType = 1; jn.Staff = (int)ViewState["PlanStaff"]; jn.BeginTime = day.AddHours(8.5); jn.EndTime = day.AddHours(17.5); jn.WorkingClassify = (int)dt.Rows[i]["WorkingClassify"]; if (jn.WorkingClassify == 1) { jn.RelateClient = (int)dt.Rows[i]["RelateClient"]; jn.Title = "[客户拜访]" + dt.Rows[i]["RelateClientName"] + jn.Title; } if (jn.WorkingClassify == 2) { jn.RelateStaff = (int)dt.Rows[i]["RelateStaff"]; jn["CCSynergeticStaff"] = "N"; jn.Title = "[协同拜访]" + dt.Rows[i]["RelateStaffName"] + jn.Title; } jn.OfficialCity = (int)dt.Rows[i]["OfficialCity"]; jn["IPAddress"] = Request.UserHostAddress; jn["IPLocation"] = Const_IPLocationBLL.FindByIP(Request.UserHostAddress).Location; jn.ApproveFlag = 2; jn.InsertStaff = (int)Session["UserID"]; NewJournals.Add(jn); //如果每天都生成一条独立的日志,则启用这一行 jn = null; } else { jn.EndTime = day.AddHours(17); } #endregion } else { jn = null; } day = day.AddDays(1); } } #endregion #region 将数据库中已存的计划与IList作比较,相同的从List中移除,不存在于List中的从数据中移除 JN_WorkingPlanBLL bll = new JN_WorkingPlanBLL((int)ViewState["PlanID"]); string con = "Staff = " + bll.Model.Staff.ToString() + " AND BeginTime BETWEEN '" + bll.Model.BeginDate.ToString("yyyy-MM-dd") + "' AND '" + bll.Model.EndDate.ToString("yyyy-MM-dd 23:59:59") + "' " + " AND JournalType = 1"; IList <JN_Journal> OrgJournals = JN_JournalBLL.GetModelList(con); foreach (JN_Journal orgitem in OrgJournals) { JN_Journal m = null; if (orgitem.WorkingClassify == 1) { m = NewJournals.FirstOrDefault(p => p.WorkingClassify == orgitem.WorkingClassify && p.RelateClient == orgitem.RelateClient && p.BeginTime.Date == orgitem.BeginTime.Date && p.EndTime.Date == orgitem.EndTime.Date); } else if (orgitem.WorkingClassify == 2) { m = NewJournals.FirstOrDefault(p => p.WorkingClassify == orgitem.WorkingClassify && p.RelateStaff == orgitem.RelateStaff && p.BeginTime.Date == orgitem.BeginTime.Date && p.EndTime.Date == orgitem.EndTime.Date); } else { m = NewJournals.FirstOrDefault(p => p.WorkingClassify == orgitem.WorkingClassify && p.OfficialCity == orgitem.OfficialCity && p.Title == orgitem.Title && p.BeginTime.Date == orgitem.BeginTime.Date && p.EndTime.Date == orgitem.EndTime.Date); } if (m == null) { new JN_JournalBLL(orgitem.ID).Delete(); //删除日志 } else { NewJournals.Remove(m); } } #endregion #region 将剩余下来的计划,新增到数据库中 foreach (JN_Journal item in NewJournals) { JN_JournalBLL jnbll = new JN_JournalBLL(); jnbll.Model = item; jnbll.Add(); } #endregion BindGrid(); MessageBox.ShowAndRedirect(this, "与该计划相关联的实际工作日志填报保存成功!", "JournalOnWorkingPlan.aspx?PlanID=" + ViewState["PlanID"].ToString()); } }
private void BindData() { JN_Journal m = new JN_JournalBLL((int)ViewState["ID"]).Model; pl_detail.BindData(m); if (m.InsertStaff != (int)Session["UserID"] || m.ApproveFlag == 1 || (DateTime.Today - m.InsertTime.Date).Days > 7) { pl_detail.SetControlsEnable(false); UploadFile1.CanDelete = false; UploadFile1.CanUpload = false; bt_OK.Visible = false; bt_Delete.Visible = false; } if ((DateTime.Today - m.InsertTime.Date).Days > 0) bt_Delete.Visible = false; //只能删除当日的日志 #region 展示附件 UploadFile1.RelateID = (int)ViewState["ID"]; UploadFile1.RelateType = 90; UploadFile1.BindGrid(); #endregion lb_CommentCounts.Text = JN_JournalCommentBLL.GetModelList("JournalID=" + ViewState["ID"].ToString()).Count.ToString(); }
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_Save_Click(object sender, EventArgs e) { if (ViewState["WorkingPlanData"] != null) { DataTable dt = (DataTable)ViewState["WorkingPlanData"]; DateTime begindate = (DateTime)ViewState["BeginDate"]; DateTime enddate = (DateTime)ViewState["EndDate"]; #region 将界面中已选择的日志放入IList中 IList<JN_Journal> NewJournals = new List<JN_Journal>(); for (int i = 0; i < dt.Rows.Count; i++) { JN_Journal jn = null; DateTime day = begindate; while (day <= enddate) { if ((bool)dt.Rows[i]["J" + day.ToString("MMdd")]) { #region 新增日志 if (jn == null) { jn = new JN_Journal(); jn.Title = (string)dt.Rows[i]["Description"]; jn.OrganizeCity = new Org_StaffBLL((int)ViewState["PlanStaff"]).Model.OrganizeCity; jn.JournalType = 1; jn.Staff = (int)ViewState["PlanStaff"]; jn.BeginTime = day.AddHours(8.5); jn.EndTime = day.AddHours(17.5); jn.WorkingClassify = (int)dt.Rows[i]["WorkingClassify"]; if (jn.WorkingClassify == 1) { jn.RelateClient = (int)dt.Rows[i]["RelateClient"]; jn.Title = "[客户拜访]" + dt.Rows[i]["RelateClientName"] + jn.Title; } if (jn.WorkingClassify == 2) { jn.RelateStaff = (int)dt.Rows[i]["RelateStaff"]; jn["CCSynergeticStaff"] = "N"; jn.Title = "[协同拜访]" + dt.Rows[i]["RelateStaffName"] + jn.Title; } jn.OfficialCity = (int)dt.Rows[i]["OfficialCity"]; jn["IPAddress"] = Request.UserHostAddress; jn["IPLocation"] = Const_IPLocationBLL.FindByIP(Request.UserHostAddress).Location; jn.ApproveFlag = 2; jn.InsertStaff = (int)Session["UserID"]; NewJournals.Add(jn); //如果每天都生成一条独立的日志,则启用这一行 jn = null; } else { jn.EndTime = day.AddHours(17); } #endregion } else { jn = null; } day = day.AddDays(1); } } #endregion #region 将数据库中已存的计划与IList作比较,相同的从List中移除,不存在于List中的从数据中移除 JN_WorkingPlanBLL bll = new JN_WorkingPlanBLL((int)ViewState["PlanID"]); string con = "Staff = " + bll.Model.Staff.ToString() + " AND BeginTime BETWEEN '" + bll.Model.BeginDate.ToString("yyyy-MM-dd") + "' AND '" + bll.Model.EndDate.ToString("yyyy-MM-dd 23:59:59") + "' " + " AND JournalType = 1"; IList<JN_Journal> OrgJournals = JN_JournalBLL.GetModelList(con); foreach (JN_Journal orgitem in OrgJournals) { JN_Journal m = null; if (orgitem.WorkingClassify == 1) { m = NewJournals.FirstOrDefault(p => p.WorkingClassify == orgitem.WorkingClassify && p.RelateClient == orgitem.RelateClient && p.BeginTime.Date == orgitem.BeginTime.Date && p.EndTime.Date == orgitem.EndTime.Date); } else if (orgitem.WorkingClassify == 2) { m = NewJournals.FirstOrDefault(p => p.WorkingClassify == orgitem.WorkingClassify && p.RelateStaff == orgitem.RelateStaff && p.BeginTime.Date == orgitem.BeginTime.Date && p.EndTime.Date == orgitem.EndTime.Date); } else { m = NewJournals.FirstOrDefault(p => p.WorkingClassify == orgitem.WorkingClassify && p.OfficialCity == orgitem.OfficialCity && p.Title == orgitem.Title && p.BeginTime.Date == orgitem.BeginTime.Date && p.EndTime.Date == orgitem.EndTime.Date); } if (m == null) new JN_JournalBLL(orgitem.ID).Delete(); //删除日志 else NewJournals.Remove(m); } #endregion #region 将剩余下来的计划,新增到数据库中 foreach (JN_Journal item in NewJournals) { JN_JournalBLL jnbll = new JN_JournalBLL(); jnbll.Model = item; jnbll.Add(); } #endregion BindGrid(); MessageBox.ShowAndRedirect(this, "与该计划相关联的实际工作日志填报保存成功!", "JournalOnWorkingPlan.aspx?PlanID=" + ViewState["PlanID"].ToString()); } }