/// <summary> ///点击确定按钮触发的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button_sumbit_Click(object sender, EventArgs e) { try { string NAME = this.txtCardName.Text;//获取到资金卡名称 if (String.IsNullOrEmpty(NAME)) { tag.Text = "名称不能为空,请填写名称!"; return; } bool checkName = bCash_CardsExt.Exists(NAME); if (checkName) { tag.Text = "该名称已经存在,请修改!"; return; } if (string.IsNullOrEmpty(TB_DateTime.Value) || DateTime.Parse(TB_DateTime.Value) < DateTime.Parse(DateTime.Now.ToLongDateString())) { tag.Text = "到期日期必须大于或等于当前日期"; return; } if (!Cash_CarDetailMX1.ReturnTnF()) { tag.Text = "未添加明细,请添加!"; return; } int intMaxID = bCash_Cards.GetMaxId(); int ZJK = 0; DataTable dt = new DataTable(); dt = bCash_Cards.GetList("Statas=0 or Statas=1").Tables[0]; if (dt.Rows.Count > 0) { ZJK = dt.Rows.Count; } mCash_Cards = new Dianda.Model.Cash_Cards(); mCash_Cards.ID = intMaxID; string time = DateTime.Now.ToString("yyyyMMdd"); //资金卡编号 mCash_Cards.CardNum = "zjk" + time + ZJK.ToString("0000"); //资金卡名称 mCash_Cards.CardName = NAME; //所属项目 mCash_Cards.ProjectID = Int32.Parse(this.ddlProjectID.SelectedValue); //所属预算报告 mCash_Cards.SFOrderID = int.Parse(DDL_Budget.SelectedValue.ToString()); //所属部门 mCash_Cards.DepartmentID = this.ddlDepartmentID.SelectedValue; //持卡人 mCash_Cards.CardholderID = this.ddlCardholderID.SelectedValue; //到期时间 mCash_Cards.EndTime = DateTime.Parse(TB_DateTime.Value); //审批人 mCash_Cards.ApproverIDs = this.ddlApproverIDs.SelectedValue; //创建日期 mCash_Cards.DATETIME = DateTime.Now; //状态 mCash_Cards.Statas = 1; //创建人 mCash_Cards.DoUserID = ((Model.USER_Users)Session["USER_Users"]).USERNAME; //新建时,可用金额和预算金额及当前余额都是一样 decimal Balance = decimal.Parse(Cash_CarDetailMX1.Balance); //预算金额 mCash_Cards.Balance = Balance; //可用金额 mCash_Cards.LimitNums = Balance; //当前余额 mCash_Cards.YEBalance = Balance; int carid = bCash_CardsExt.Add(mCash_Cards); Cash_CarDetailMX1.Submit(carid); /*-------------------资金卡明细----------begin--------*/ //开始操作资金卡明细信息 //GridView GV = Cash_CarDetailList.GV1; //if (GV.Rows.Count > 0) //{ // Model.Cash_CardsDetail cardsdetail_model = new Dianda.Model.Cash_CardsDetail(); // BLL.Cash_CardsDetail cardsdetail_bll = new Dianda.BLL.Cash_CardsDetail(); // for (int i = 0; i < GV.Rows.Count; i++) // { // HiddenField HF_DetailID = (HiddenField)GV.Rows[i].FindControl("HiddenField_deid"); // TextBox TB_balance = (TextBox)GV.Rows[i].FindControl("TextBox_balance"); // DropDownList DropDownList_Unit = (DropDownList)GV.Rows[i].FindControl("DropDownList_Unit"); // int Unit = int.Parse(DropDownList_Unit.SelectedValue.ToString()); // RadioButtonList RadioButtonList_typename = (RadioButtonList)GV.Rows[i].FindControl("RadioButtonList_typename"); // //ID // cardsdetail_model.ID = cardsdetail_bll.GetMaxId(); // //资金卡ID // cardsdetail_model.CardID = carid; // //明细项目的ID // cardsdetail_model.DetailID = int.Parse(HF_DetailID.Value.ToString()); // //在新建资金卡时,预算金额、可用金额、当前余额都是一样的 // //各明细项的当前余额 // cardsdetail_model.Balance = decimal.Parse(TB_balance.Text.ToString()) * Unit; // //预算金额 // cardsdetail_model.Oldbalance = decimal.Parse(TB_balance.Text.ToString()) * Unit; // //可用金额 // cardsdetail_model.KYbalance = decimal.Parse(TB_balance.Text.ToString()) * Unit; // //单位 // cardsdetail_model.Unit = Unit; // //细目的类型 // cardsdetail_model.TypesName = RadioButtonList_typename.SelectedValue.ToString(); // cardsdetail_bll.Add(cardsdetail_model); // } //} /*-------------------资金卡明细----------begin--------*/ /*---------------------一旦为某一个预算报告新创建了一个新的资金卡,就要在预算报告的资金卡数量上加1 -----------begin--------------*/ BLL.Cash_SF_Order order_bll = new Dianda.BLL.Cash_SF_Order(); Model.Cash_SF_Order order_model = new Dianda.Model.Cash_SF_Order(); string SFOrderID = mCash_Cards.SFOrderID.ToString(); order_model = order_bll.GetModel(int.Parse(SFOrderID)); //资金卡数量加1 order_model.CarNums = order_model.CarNums + 1; order_bll.Update(order_model); /*---------------------一旦为某一个预算报告新创建了一个新的资金卡,就要在预算报告的资金卡数量上加1---------------end------------*/ Cash_CarDetailMX1.main(carid.ToString()); tag.Text = "操作成功!"; tag2.Text = "操作成功!"; this.lblCardNum.Text = mCash_Cards.CardNum; this.Button_sumbit.Visible = false; //this.Button_reset.Visible = false; //string coutws = "<script language=\"javascript\" type=\"text/javascript\">alert(\"操作成功!现在进入列表页面\"); location.href = \"manage.aspx" + "\";</script>"; //Response.Write(coutws); //添加操作日志 Dianda.BLL.SYS_LogsExt bsyslog = new Dianda.BLL.SYS_LogsExt(); Model.USER_Users user_model = (Model.USER_Users)Session["USER_Users"]; bsyslog.addlogs(((Model.USER_Users)Session["USER_Users"]).REALNAME + "(" + ((Model.USER_Users)Session["USER_Users"]).USERNAME + ")", "新增资金卡", "新增资金卡" + mCash_Cards.CardNum + "成功"); //添加操作日志 string coutws = "alert(\"操作成功!现在返回列表页面\"); "; coutws += "location.href = \"manage.aspx?pageindex=" + Request["pageindex"] + "\";"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "addScript", coutws, true); } catch { tag.Text = "操作失败,请重试!"; } }
/// <summary> ///点击确定按钮触发的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button_sumbit_Click(object sender, EventArgs e) { try { string NAME = this.txtCardName.Text;//获取到资金卡名称 if (String.IsNullOrEmpty(NAME)) { tag.Text = "名称不能为空,请填写名称!"; return; } if (string.IsNullOrEmpty(TB_DateTime.Value) || DateTime.Parse(TB_DateTime.Value) < DateTime.Parse(DateTime.Now.ToLongDateString())) { tag.Text = "到期日期必须大于或等于当前日期"; return; } if (!Cash_CarDetailMX1.ReturnTnF()) { tag.Text = "未添加明细,请添加!"; return; } Cards_model = Cards_bll.GetModel(Int32.Parse(id)); //资金卡名称 Cards_model.CardName = NAME; //所属项目 Cards_model.ProjectID = Int32.Parse(this.ddlProjectID.SelectedValue); //所属预算报告 Cards_model.SFOrderID = int.Parse(DDL_Budget.SelectedValue.ToString()); //所属部门 Cards_model.DepartmentID = this.ddlDepartmentID.SelectedValue; //持卡人 Cards_model.CardholderID = this.ddlCardholderID.SelectedValue; //到期时间 Cards_model.EndTime = DateTime.Parse(TB_DateTime.Value); //审批人 Cards_model.ApproverIDs = this.ddlApproverIDs.SelectedValue; //创建日期 Cards_model.DATETIME = DateTime.Now; //状态 Cards_model.Statas = 1; //创建人 Cards_model.DoUserID = ((Model.USER_Users)Session["USER_Users"]).USERNAME; //原可用金额 string oldLimitNums = Cards_model.LimitNums.ToString(); //调整后的可用金额 string newLimitNums = Cash_CarDetailMX1.LimitNums; //差额 decimal cj = decimal.Parse(newLimitNums) - decimal.Parse(oldLimitNums); if (cj > 0) { //当前余额(可用金额增加或减少多少,当前余额对应的调整) Cards_model.YEBalance = Cards_model.YEBalance + cj; Cards_model.TEMP0 = Cards_model.TEMP0 + " " + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + ",增加" + cj + "元,可用金额由" + oldLimitNums + "元调整为" + newLimitNums + "元<br>"; } else { cj = decimal.Parse(oldLimitNums) - decimal.Parse(newLimitNums); //当前余额(可用金额增加或减少多少,当前余额对应的调整) Cards_model.YEBalance = Cards_model.YEBalance - cj; Cards_model.TEMP0 = Cards_model.TEMP0 + " " + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + ",减少" + cj + "元,可用金额由" + oldLimitNums + "元调整为" + newLimitNums + "元<br>"; } //可用金额 Cards_model.LimitNums = decimal.Parse((newLimitNums)); //预算金额 Cards_model.Balance = decimal.Parse((Cash_CarDetailMX1.Balance)); Cards_bll.Update(Cards_model); Cash_CarDetailMX1.CJ = cj; Cash_CarDetailMX1.Submit(int.Parse(id)); /*-------------------资金卡明细----------begin-----------------------*/ //开始操作资金卡明细信息 //GridView GV = Cash_CarDetailList.GV1; //if (GV.Rows.Count > 0) //{ // Model.Cash_CardsDetail cardsdetail_model = new Dianda.Model.Cash_CardsDetail(); // BLL.Cash_CardsDetail cardsdetail_bll = new Dianda.BLL.Cash_CardsDetail(); // for (int i = 0; i < GV.Rows.Count; i++) // { // HiddenField HF_ID = (HiddenField)GV.Rows[i].FindControl("HiddenField_ID"); // HiddenField HF_DetailID = (HiddenField)GV.Rows[i].FindControl("HiddenField_deid"); // TextBox TB_balance = (TextBox)GV.Rows[i].FindControl("TextBox_balance"); // DropDownList DropDownList_Unit = (DropDownList)GV.Rows[i].FindControl("DropDownList_Unit"); // int Unit = int.Parse(DropDownList_Unit.SelectedValue.ToString()); // RadioButtonList RadioButtonList_typename = (RadioButtonList)GV.Rows[i].FindControl("RadioButtonList_typename"); // cardsdetail_model = cardsdetail_bll.GetModel(int.Parse(HF_ID.Value.ToString())); // //资金卡ID // cardsdetail_model.CardID =int.Parse(id); // //明细项目的ID // cardsdetail_model.DetailID = int.Parse(HF_DetailID.Value.ToString()); // //编辑时,预算金额不变,还是最初始的值,但是可用金额有可能被调整了。。那么当前余额也要对应增加或减 // //当前余额 (可用金额调整额度是多少,就要在原来的当前余额基础上加减多少) // if (cj > 0) // { // //首先获得可用金额调整的差值 // decimal cz = decimal.Parse(TB_balance.Text.ToString()) * Unit - decimal.Parse(cardsdetail_model.KYbalance.ToString()); // cardsdetail_model.Balance = cardsdetail_model.Balance + cz; // } // else // { // //首先获得可用金额调整的差值 // decimal cz = decimal.Parse(cardsdetail_model.KYbalance.ToString()) - decimal.Parse(TB_balance.Text.ToString()) * Unit; // cardsdetail_model.Balance = cardsdetail_model.Balance - cz; // } // //可用金额 // cardsdetail_model.KYbalance = decimal.Parse(TB_balance.Text.ToString()) * Unit; // //单位 // cardsdetail_model.Unit = Unit; // //细目的类型 // cardsdetail_model.TypesName = RadioButtonList_typename.SelectedValue.ToString(); // cardsdetail_bll.Update(cardsdetail_model); // } //} /*-------------------资金卡明细----------begin-------------------------------*/ tag.Text = "操作成功!"; tag2.Text = "操作成功!"; this.TB_CardNum.Text = Cards_model.CardNum.ToString(); this.Button_sumbit.Visible = false; //添加操作日志 Dianda.BLL.SYS_LogsExt bsyslog = new Dianda.BLL.SYS_LogsExt(); Model.USER_Users user_model = (Model.USER_Users)Session["USER_Users"]; bsyslog.addlogs(((Model.USER_Users)Session["USER_Users"]).REALNAME + "(" + ((Model.USER_Users)Session["USER_Users"]).USERNAME + ")", "编辑资金卡", "编辑资金卡" + Cards_model.CardNum + "成功"); //添加操作日志 string coutws = "alert(\"操作成功!现在返回列表页面\"); "; coutws += "location.href = \"manage.aspx?pageindex=" + Request["pageindex"] + "&role=manage\";"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "addScript", coutws, true); } catch { tag.Text = "操作失败,请重试!"; } }