Esempio n. 1
0
 protected void btnok_Click(object sender, EventArgs e)
 {
     Maticsoft.BLL.Product   probll   = new Maticsoft.BLL.Product();
     Maticsoft.Model.Product promodel = new Maticsoft.Model.Product();
     if (txtprotitle.Text.Trim() == "")
     {
         lbltitle.Text = "请填写产品名称";
         return;
     }
     promodel.ProName = txtprotitle.Text.Trim();
     lbltitle.Text    = "";
     try
     {
         promodel.ProTypeID = int.Parse(drptype.SelectedValue);
     }
     catch (Exception e1)
     { }
     try
     {
         promodel.ProXingID = int.Parse(drpxing.SelectedValue);
     }
     catch (Exception e2)
     { }
     if (txttme.Text.Trim() == "")
     {
         lblprotime.Text = "请填写产品出品时间";
         return;
     }
     promodel.Prochutime = Convert.ToDateTime(txttme.Text.Trim());
     lblprotime.Text     = "";
     if (txtfatime.Text.Trim() == "")
     {
         lbltime.Text = "请填写发布时间";
         return;
     }
     promodel.Fatime     = Convert.ToDateTime(txtfatime.Text.Trim());
     lbltime.Text        = "";
     promodel.ImageURL   = Image1.ImageUrl;
     promodel.Toujian    = 0;
     promodel.Procontent = txtprocontent.Text.Trim();
     probll.Add(promodel);
     Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息添加成功!')</script>");
     txtprotitle.Text   = string.Empty;
     txttme.Text        = string.Empty;
     txtfatime.Text     = string.Empty;
     txtprocontent.Text = string.Empty;
 }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtProName.Text.Trim().Length == 0)
            {
                strErr += "ProName不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtProTypeID.Text))
            {
                strErr += "ProTypeID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtProXingID.Text))
            {
                strErr += "ProXingID格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtProchutime.Text))
            {
                strErr += "Prochutime格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtFatime.Text))
            {
                strErr += "Fatime格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtHitNum.Text))
            {
                strErr += "HitNum格式错误!\\n";
            }
            if (this.txtProcontent.Text.Trim().Length == 0)
            {
                strErr += "Procontent不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   ProName    = this.txtProName.Text;
            int      ProTypeID  = int.Parse(this.txtProTypeID.Text);
            int      ProXingID  = int.Parse(this.txtProXingID.Text);
            DateTime Prochutime = DateTime.Parse(this.txtProchutime.Text);
            DateTime Fatime     = DateTime.Parse(this.txtFatime.Text);
            bool     Toujian    = this.chkToujian.Checked;
            int      HitNum     = int.Parse(this.txtHitNum.Text);
            string   Procontent = this.txtProcontent.Text;

            Maticsoft.Model.Product model = new Maticsoft.Model.Product();
            model.ProName    = ProName;
            model.ProTypeID  = ProTypeID;
            model.ProXingID  = ProXingID;
            model.Prochutime = Prochutime;
            model.Fatime     = Fatime;
            model.Toujian    = Toujian;
            model.HitNum     = HitNum;
            model.Procontent = Procontent;

            Maticsoft.BLL.Product bll = new Maticsoft.BLL.Product();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }