コード例 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!base.IsPostBack)
     {
         if (base.Request["Id"] != null)
         {
             this.btnAdd.Visible = false;
             FpTaxInfo model = this.goodSer.GetModel(Convert.ToInt32(base.Request["Id"]));
             this.txtFpType.Text = model.FpType;
             this.txtTax.Text    = model.Tax.ToString();
         }
         else
         {
             this.btnUpdate.Visible = false;
         }
     }
 }
コード例 #2
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (this.FormCheck())
     {
         try
         {
             string sqlCheck = string.Format("select count(*) from FpTaxInfo where FpType='{0}'",
                                             txtFpType.Text);
             if (Convert.ToInt32(DBHelp.ExeScalar(sqlCheck)) > 0)
             {
                 base.ClientScript.RegisterStartupScript(base.GetType(), null, string.Format("<script>alert('发票类型名称[{0}],已经存在!');</script>", txtFpType.Text));
                 return;
             }
             sqlCheck = string.Format("select count(*) from FpTaxInfo where TAX={0} ",
                                      txtTax.Text);
             if (Convert.ToInt32(DBHelp.ExeScalar(sqlCheck)) > 0)
             {
                 base.ClientScript.RegisterStartupScript(base.GetType(), null, string.Format("<script>alert('发票税收点数[{0}],已经存在!');</script>", txtFpType.Text));
                 return;
             }
             FpTaxInfo model = getModel();
             if (this.goodSer.Add(model) > 0)
             {
                 base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('添加成功!');</script>");
                 Clear();
             }
             else
             {
                 base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('添加失败!');</script>");
             }
         }
         catch (Exception ex)
         {
             base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('" + ex.Message + "!');</script>");
         }
     }
 }