Ejemplo n.º 1
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void LinkButton2_Click(object sender, EventArgs e)
 {
     try
     {
         //获取button 控件
         LinkButton lb = (LinkButton)sender;
         //获取传过来的commwntid
         int     id = Convert.ToInt32(lb.CommandArgument);
         DataSet ds = ot.GetList(" HomemadeID=" + id + "");
         if (ds.Tables[0].Rows.Count > 0)
         {
             Model.Homemadetab hom = hot.GetModel(id);
             hom.BY1 = 0;
             bool bb = hot.Update(hom);
             if (bb == true)
             {
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('停用成功!');</script>");
                 bind(sql);
             }
             else
             {
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('停用失败!');</script>");
                 bind(sql);
             }
         }
         else
         {
             bool aa = hot.Delete(id);
             if (aa == true)
             {
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('删除成功!');</script>");
                 bind(sql);
             }
             else
             {
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('删除失败!');</script>");
                 bind(sql);
             }
         }
     }
     catch (Exception ee)
     {
         //Response.Write("<script>alert('确定异常 " + ee.Message + "')</script>");
         ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('删除异常 " + ee.Message + "');</script>");
     }
 }
Ejemplo n.º 2
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtName.Text.Trim().Length == 0)
            {
                strErr += "Name不能为空!\\n";
            }
            if (this.txtPhotourl.Text.Trim().Length == 0)
            {
                strErr += "Photourl不能为空!\\n";
            }
            if (this.txtComment.Text.Trim().Length == 0)
            {
                strErr += "Comment不能为空!\\n";
            }
            if (this.txtBeizhu.Text.Trim().Length == 0)
            {
                strErr += "Beizhu不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtBY1.Text))
            {
                strErr += "BY1格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtBY2.Text))
            {
                strErr += "BY2格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtBY3.Text))
            {
                strErr += "BY3格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int     id       = int.Parse(this.lblid.Text);
            string  Name     = this.txtName.Text;
            string  Photourl = this.txtPhotourl.Text;
            string  Comment  = this.txtComment.Text;
            string  Beizhu   = this.txtBeizhu.Text;
            decimal BY1      = decimal.Parse(this.txtBY1.Text);
            decimal BY2      = decimal.Parse(this.txtBY2.Text);
            decimal BY3      = decimal.Parse(this.txtBY3.Text);

            byte[] BY4 = new UnicodeEncoding().GetBytes(this.txtBY4.Text);
            byte[] BY5 = new UnicodeEncoding().GetBytes(this.txtBY5.Text);
            byte[] BY6 = new UnicodeEncoding().GetBytes(this.txtBY6.Text);
            byte[] BY7 = new UnicodeEncoding().GetBytes(this.txtBY7.Text);


            Maticsoft.Model.Homemadetab model = new Maticsoft.Model.Homemadetab();
            model.id       = id;
            model.Name     = Name;
            model.Photourl = Photourl;
            model.Comment  = Comment;
            model.Beizhu   = Beizhu;
            model.BY1      = BY1;
            model.BY2      = BY2;
            model.BY3      = BY3;
            model.BY4      = BY4;
            model.BY5      = BY5;
            model.BY6      = BY6;
            model.BY7      = BY7;

            Maticsoft.BLL.Homemadetab bll = new Maticsoft.BLL.Homemadetab();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }