コード例 #1
0
ファイル: DeductSalaryView.aspx.cs プロジェクト: 892182825/SP
    /// <summary>
    /// 提交
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        this.question.Text = question.Text.Trim();
        this.money.Text    = money.Text.Trim();

        //设置特定值防止重复提交
        hid_fangzhi.Value = "0";

        if (this.rad_Deduct.SelectedValue == "")
        {
            ScriptHelper.SetAlert(Page, GetTran("007748", "请选择补扣款项"));
            return;
        }
        string    number = "";
        string    sql    = "select number from MemberInfo where MobileTele='" + txtbh.Text + "'";
        DataTable shj    = DBHelper.ExecuteDataTable(sql);

        if (shj.Rows.Count > 0)
        {
            number = shj.Rows[0][0].ToString();
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("002096", "无此编号,请检查后再重新输入") + "!')</script>");
            return;
        }


        if (number != "" && this.question.Text != "" && this.money.Text != "")
        {
            string vquestion;

            //判断会员是否存在
            if (DeductBLL.IsExist(number))
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("002096", "无此编号,请检查后再重新输入") + "!')</script>");
                return;
            }
            double d;
            if (!double.TryParse(money.Text, out d))
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("002095", "金额输入有误") + "!')</script>");
                return;
            }
            if (d <= 0)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script >alert('" + GetTran("001539", "操作失败,输入的金额不能小于0") + "!')</script>");
                return;
            }
            else
            {
                int iskou = int.Parse(rad_Deduct.SelectedValue); //0为扣,1为补

                vquestion = this.question.Text.Trim();
                DeductModel model = new DeductModel();
                model.Number       = DisposeString.DisString(number.Trim(), "<,>,',-", "&lt;,&gt;,&#39;,&nbsp;", ",");
                model.DeductMoney  = d;
                model.DeductReason = vquestion;
                model.ExpectNum    = CommonDataBLL.getMaxqishu();
                model.IsDeduct     = iskou;
                model.Actype       = 1;
                model.OperateIP    = CommonDataBLL.OperateIP;
                model.OperateNum   = CommonDataBLL.OperateBh;
                try
                {
                    if (DeductBLL.AddDeduct(model))
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "", "<script >alert('" + GetTran("000006", "添加成功") + "!');window.location.href='DeductSalary.aspx';</script>");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "", "<script >alert('" + GetTran("000007", "添加失败") + "!')</script>");
                    }
                }
                catch (Exception)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "", "<script >alert('" + GetTran("001507", "操作失败") + "!')</script>");
                }
            }
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script >alert('" + GetTran("002094", "所有项必填,请重新输入") + "!')</script>");
        }
        clear();
    }