Example #1
0
    //protected void Button1_Click(object sender, EventArgs e)
    //{
    //    txtBxzy.Text = Request["a"];

    //    //Response.Write(Request["a"]);
    //}

    protected void btnSave_Click(object sender, EventArgs e)
    {
        string ysGuid   = (new GuidHelper()).getNewGuid();
        string billName = txtBillCode.Text.Trim();
        string flowid   = hd_djtype.Value;
        string billUser = (string)Session["userCode"];
        string date     = txtBillDate.Text.Trim();

        //beg发布时间
        if (this.txtBillDate.Text.Trim() != "")
        {
            DateTime date1 = DateTime.MinValue;
            bool     flag  = DateTime.TryParse(this.txtBillDate.Text.ToString(), out date1);
            if (flag)
            {
                date = date1.ToString("yyyy-MM-dd");
            }
            else
            {
                Response.Write("<script>alert('日期格式错误!');</script>");
                txtBillDate.Focus();
                return;
            }
        }
        else
        {
            Response.Write("<script>alert('请填制单日期!');</script>");
            return;
        }
        //end发布时间



        string dept   = PubMethod.SubString(txtBillDept.Text.Trim());
        string isgk   = ddlIsGk.SelectedValue == "是" ? "1" : "0";
        string gkdept = isgk == "0" ? dept : ddlGkDept.SelectedValue;
        string bxlx   = ddlBxmxlx.SelectedValue;
        string bxzy   = txtBxzy.Text.Trim();
        string bxsm   = txtBxsm.Text.Trim();
        string sql    = string.Format("insert into ph_main ([billCode],[billName]  ,[flowID] ,[stepID] ,[billUser] ,[bxr] ,[billDate] ,[billDept] ,[loopTimes] ,[isgk] ,[gkdept] ,[bxmxlx] ,[bxzy] ,[bxsm])   values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}')", ysGuid, billName, flowid, "-1", billUser, billUser, date, dept, "0", isgk, gkdept, bxlx, bxzy, bxsm);

        if (server.ExecuteNonQuery(sql) > 0)
        {
            Response.Redirect("ybbxEditItem.aspx?billCode=" + ysGuid);
        }
    }
Example #2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        bill_travelApplicationBLL bllTravelApplication = new bill_travelApplicationBLL();



        string strCtrl      = Request["type"];
        string strBillCode  = Request["billCode"];
        string str_billuser = PubMethod.SubString(txt_billUser.Text);
        string users        = hfuser.Value;

        if (string.IsNullOrEmpty(users))
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "alert('出差人不能为空!');", true);
            return;
        }
        string[] userArr       = users.Split(',');
        string   travelPersons = "";

        for (int i = 0; i < userArr.Length; i++)
        {
            if (travelPersons.IndexOf(userArr[i]) != -1)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('有重复的出差人!');", true);
                return;
            }
            travelPersons += "|&|" + PubMethod.SubString(userArr[i]);
        }


        string str_billdate = txt_billDate.Text.Trim();
        string str_billdept = server.GetCellValue("select userdept from bill_users where usercode='" + str_billuser + "'");
        string bm           = PubMethod.SubString(txt_userDept.Text);
        //申请表
        Bill_TravelApplication modelTravelApplication = new Bill_TravelApplication();
        //主表
        Bill_Main modelMainBill = new Bill_Main();
        string    strMsg        = "";

        try
        {
            //添加修改
            if (strCtrl.Equals("edit") && strBillCode.Equals(""))
            {
                if (strBillCode.Equals(""))
                {
                    throw new Exception("单号丢失!");
                }
                modelTravelApplication = bllTravelApplication.GetModel(strBillCode);
            }

            //添加
            modelMainBill.BillName  = "出差管理单";
            modelMainBill.BillType  = "";
            modelMainBill.BillUser  = str_billuser;
            modelMainBill.FlowId    = "ccsq";
            modelMainBill.GkDept    = "";
            modelMainBill.IsGk      = "";
            modelMainBill.LoopTimes = 0;
            modelMainBill.StepId    = "-1";

            //出差申请单表
            modelTravelApplication.arrdess          = this.txt_address.Text.Trim();
            modelTravelApplication.maincode         = txt_bh.Text.Trim();
            modelTravelApplication.MoreThanStandard = Convert.ToInt32(ddlIsbz.SelectedValue);
            //modelTravelApplication.needAmount = int.Parse(this.txtFeePlan.Text.Trim());
            modelTravelApplication.reasion    = this.txt_reasion.Text.Trim();
            modelTravelApplication.Transport  = this.txt_jtgj.Text.Trim();
            modelTravelApplication.travelDate = this.txt_travelDate.Text.Trim();

            modelTravelApplication.sendDept = PubMethod.SubString(txt_bm.Text);
            string strAppPersion = this.txt_billUser.Text.Trim();
            if (string.IsNullOrEmpty(strAppPersion))
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('申请人不能为空!');", true);
                return;
            }
            modelTravelApplication.travelPersionCode = travelPersons;
            modelTravelApplication.travelplan        = this.txt_plan.Text.Trim();;

            modelTravelApplication.jiaotongfei    = ToIntNum(txt_jtf.Text);
            modelTravelApplication.zhusufei       = ToIntNum(txt_zsf.Text);
            modelTravelApplication.yewuzhaodaifei = ToIntNum(txt_zdf.Text);
            modelTravelApplication.huiyifei       = ToIntNum(txt_hyf.Text);
            modelTravelApplication.yinshuafei     = ToIntNum(txt_ysf.Text);
            modelTravelApplication.qitafei        = ToIntNum(txt_qt.Text);
            modelTravelApplication.needAmount     = modelTravelApplication.jiaotongfei + modelTravelApplication.zhusufei + modelTravelApplication.yewuzhaodaifei + modelTravelApplication.huiyifei + modelTravelApplication.yinshuafei + modelTravelApplication.qitafei;
            modelMainBill.BillJe = (decimal)modelTravelApplication.needAmount;
            //if (this.ddlTravelType.SelectedValue == null)
            //{
            //    throw new Exception("出差类型不能为空!");
            //}
            //modelTravelApplication.typecode = this.ddlTravelType.SelectedValue.Trim();

            modelMainBill.BillCode = txt_bh.Text.Trim();

            DateTime dtBillDate;
            bool     boBillDate = DateTime.TryParse(str_billdate, out dtBillDate);
            if (boBillDate)
            {
                modelMainBill.BillDate = dtBillDate;
            }
            else
            {
                throw new Exception("日期格式输入不正确!");
            }
            UserMessage user        = new UserMessage(modelMainBill.BillUser);
            string      strBillDept = user.GetRootDept().DeptCode;
            if (string.IsNullOrEmpty(strBillDept))
            {
                throw new Exception("未发现人员所在单位!");
            }
            modelMainBill.BillDept = strBillDept;
            //modelMainBill.BillJe = int.Parse(this.txtFeePlan.Text.Trim());//单据金额

            int iRel = bllTravelApplication.AddNote(modelMainBill, modelTravelApplication, out strMsg);
            if (iRel < 1)
            {
                throw new Exception(strMsg);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('保存成功!');window.location.href='travelApplyList.aspx';", true);
            }
        }
        catch (Exception ex)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "alert('保存失败,原因:" + ex.Message + "');", true);
        }
    }