Example #1
0
 private void ShowInfo(int id)
 {
     Jium.BLL.consumer   bll   = new Jium.BLL.consumer();
     Jium.Model.consumer model = bll.GetModel(id);
     //this.lblid.Text=model.id.ToString();
     this.lblcname.Text   = model.cname;
     this.lblccode.Text   = model.ccode;
     this.lblcphone.Text  = model.cphone;
     this.lblcemail.Text  = model.cemail;
     this.lblclevel.Text  = model.clevel;
     this.lblcsum.Text    = model.csum.ToString();
     this.lblcsex.Text    = model.csex.ToString();
     this.lblcremark.Text = model.cremark;
     this.lblcss1.Text    = model.css1;
     //this.lblcss2.Text=model.css2;
     //this.lblcss3.Text=model.css3;
     //this.lblcss4.Text=model.css4;
     //this.lblcss5.Text=model.css5;
     //this.lblcsd1.Text=model.csd1.ToString();
     //this.lblcsd2.Text=model.csd2.ToString();
     //this.lblcsd3.Text=model.csd3.ToString();
     //this.lblcsd4.Text=model.csd4.ToString();
     //this.lblcsd5.Text=model.csd5.ToString();
     //this.lblcsdc1.Text=model.csdc1.ToString();
     //this.lblcsdc2.Text=model.csdc2.ToString();
     //this.lblcsdc3.Text=model.csdc3.ToString();
     //this.lblcsdc4.Text=model.csdc4.ToString();
     //this.lblcsdc5.Text=model.csdc5.ToString();
 }
Example #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Jium.Model.consumer GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,cname,ccode,cphone,cemail,clevel,csum,csex,cremark,css1,css2,css3,css4,css5,csd1,csd2,csd3,csd4,csd5,csdc1,csdc2,csdc3,csdc4,csdc5 from consumer ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

            Jium.Model.consumer model = new Jium.Model.consumer();
            DataSet             ds    = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Jium.Model.consumer model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into consumer(");
            strSql.Append("cname,ccode,cphone,cemail,clevel,csum,csex,cremark,css1,css2,css3,css4,css5,csd1,csd2,csd3,csd4,csd5,csdc1,csdc2,csdc3,csdc4,csdc5)");
            strSql.Append(" values (");
            strSql.Append("@cname,@ccode,@cphone,@cemail,@clevel,@csum,@csex,@cremark,@css1,@css2,@css3,@css4,@css5,@csd1,@csd2,@csd3,@csd4,@csd5,@csdc1,@csdc2,@csdc3,@csdc4,@csdc5)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@cname",   MySqlDbType.VarChar,  40),
                new MySqlParameter("@ccode",   MySqlDbType.VarChar,  20),
                new MySqlParameter("@cphone",  MySqlDbType.VarChar,  20),
                new MySqlParameter("@cemail",  MySqlDbType.VarChar,  50),
                new MySqlParameter("@clevel",  MySqlDbType.VarChar,  11),
                new MySqlParameter("@csum",    MySqlDbType.Decimal,  20),
                new MySqlParameter("@csex",    MySqlDbType.Int32,    11),
                new MySqlParameter("@cremark", MySqlDbType.VarChar, 200),
                new MySqlParameter("@css1",    MySqlDbType.VarChar,  20),
                new MySqlParameter("@css2",    MySqlDbType.VarChar,  20),
                new MySqlParameter("@css3",    MySqlDbType.VarChar,  20),
                new MySqlParameter("@css4",    MySqlDbType.VarChar,  20),
                new MySqlParameter("@css5",    MySqlDbType.VarChar,  20),
                new MySqlParameter("@csd1",    MySqlDbType.Int32,    11),
                new MySqlParameter("@csd2",    MySqlDbType.Int32,    11),
                new MySqlParameter("@csd3",    MySqlDbType.Int32,    11),
                new MySqlParameter("@csd4",    MySqlDbType.Int32,    11),
                new MySqlParameter("@csd5",    MySqlDbType.Int32,    11),
                new MySqlParameter("@csdc1",   MySqlDbType.Decimal,  20),
                new MySqlParameter("@csdc2",   MySqlDbType.Decimal,  20),
                new MySqlParameter("@csdc3",   MySqlDbType.Decimal,  20),
                new MySqlParameter("@csdc4",   MySqlDbType.Decimal,  20),
                new MySqlParameter("@csdc5",   MySqlDbType.Decimal, 20)
            };
            parameters[0].Value  = model.cname;
            parameters[1].Value  = model.ccode;
            parameters[2].Value  = model.cphone;
            parameters[3].Value  = model.cemail;
            parameters[4].Value  = model.clevel;
            parameters[5].Value  = model.csum;
            parameters[6].Value  = model.csex;
            parameters[7].Value  = model.cremark;
            parameters[8].Value  = model.css1;
            parameters[9].Value  = model.css2;
            parameters[10].Value = model.css3;
            parameters[11].Value = model.css4;
            parameters[12].Value = model.css5;
            parameters[13].Value = model.csd1;
            parameters[14].Value = model.csd2;
            parameters[15].Value = model.csd3;
            parameters[16].Value = model.csd4;
            parameters[17].Value = model.csd5;
            parameters[18].Value = model.csdc1;
            parameters[19].Value = model.csdc2;
            parameters[20].Value = model.csdc3;
            parameters[21].Value = model.csdc4;
            parameters[22].Value = model.csdc5;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Jium.Model.consumer DataRowToModel(DataRow row)
 {
     Jium.Model.consumer model = new Jium.Model.consumer();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["cname"] != null)
         {
             model.cname = row["cname"].ToString();
         }
         if (row["ccode"] != null)
         {
             model.ccode = row["ccode"].ToString();
         }
         if (row["cphone"] != null)
         {
             model.cphone = row["cphone"].ToString();
         }
         if (row["cemail"] != null)
         {
             model.cemail = row["cemail"].ToString();
         }
         if (row["clevel"] != null)
         {
             model.clevel = row["clevel"].ToString();
         }
         if (row["csum"] != null && row["csum"].ToString() != "")
         {
             model.csum = decimal.Parse(row["csum"].ToString());
         }
         if (row["csex"] != null && row["csex"].ToString() != "")
         {
             model.csex = int.Parse(row["csex"].ToString());
         }
         if (row["cremark"] != null)
         {
             model.cremark = row["cremark"].ToString();
         }
         if (row["css1"] != null)
         {
             model.css1 = row["css1"].ToString();
         }
         if (row["css2"] != null)
         {
             model.css2 = row["css2"].ToString();
         }
         if (row["css3"] != null)
         {
             model.css3 = row["css3"].ToString();
         }
         if (row["css4"] != null)
         {
             model.css4 = row["css4"].ToString();
         }
         if (row["css5"] != null)
         {
             model.css5 = row["css5"].ToString();
         }
         if (row["csd1"] != null && row["csd1"].ToString() != "")
         {
             model.csd1 = int.Parse(row["csd1"].ToString());
         }
         if (row["csd2"] != null && row["csd2"].ToString() != "")
         {
             model.csd2 = int.Parse(row["csd2"].ToString());
         }
         if (row["csd3"] != null && row["csd3"].ToString() != "")
         {
             model.csd3 = int.Parse(row["csd3"].ToString());
         }
         if (row["csd4"] != null && row["csd4"].ToString() != "")
         {
             model.csd4 = int.Parse(row["csd4"].ToString());
         }
         if (row["csd5"] != null && row["csd5"].ToString() != "")
         {
             model.csd5 = int.Parse(row["csd5"].ToString());
         }
         if (row["csdc1"] != null && row["csdc1"].ToString() != "")
         {
             model.csdc1 = decimal.Parse(row["csdc1"].ToString());
         }
         if (row["csdc2"] != null && row["csdc2"].ToString() != "")
         {
             model.csdc2 = decimal.Parse(row["csdc2"].ToString());
         }
         if (row["csdc3"] != null && row["csdc3"].ToString() != "")
         {
             model.csdc3 = decimal.Parse(row["csdc3"].ToString());
         }
         if (row["csdc4"] != null && row["csdc4"].ToString() != "")
         {
             model.csdc4 = decimal.Parse(row["csdc4"].ToString());
         }
         if (row["csdc5"] != null && row["csdc5"].ToString() != "")
         {
             model.csdc5 = decimal.Parse(row["csdc5"].ToString());
         }
     }
     return(model);
 }
Example #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Jium.Model.consumer model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update consumer set ");
            strSql.Append("cname=@cname,");
            strSql.Append("ccode=@ccode,");
            strSql.Append("cphone=@cphone,");
            strSql.Append("cemail=@cemail,");
            strSql.Append("clevel=@clevel,");
            strSql.Append("csum=@csum,");
            strSql.Append("csex=@csex,");
            strSql.Append("cremark=@cremark,");
            strSql.Append("css1=@css1,");
            strSql.Append("css2=@css2,");
            strSql.Append("css3=@css3,");
            strSql.Append("css4=@css4,");
            strSql.Append("css5=@css5,");
            strSql.Append("csd1=@csd1,");
            strSql.Append("csd2=@csd2,");
            strSql.Append("csd3=@csd3,");
            strSql.Append("csd4=@csd4,");
            strSql.Append("csd5=@csd5,");
            strSql.Append("csdc1=@csdc1,");
            strSql.Append("csdc2=@csdc2,");
            strSql.Append("csdc3=@csdc3,");
            strSql.Append("csdc4=@csdc4,");
            strSql.Append("csdc5=@csdc5");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@cname",   MySqlDbType.VarChar,  40),
                new MySqlParameter("@ccode",   MySqlDbType.VarChar,  20),
                new MySqlParameter("@cphone",  MySqlDbType.VarChar,  20),
                new MySqlParameter("@cemail",  MySqlDbType.VarChar,  50),
                new MySqlParameter("@clevel",  MySqlDbType.VarChar,  11),
                new MySqlParameter("@csum",    MySqlDbType.Decimal,  20),
                new MySqlParameter("@csex",    MySqlDbType.Int32,    11),
                new MySqlParameter("@cremark", MySqlDbType.VarChar, 200),
                new MySqlParameter("@css1",    MySqlDbType.VarChar,  20),
                new MySqlParameter("@css2",    MySqlDbType.VarChar,  20),
                new MySqlParameter("@css3",    MySqlDbType.VarChar,  20),
                new MySqlParameter("@css4",    MySqlDbType.VarChar,  20),
                new MySqlParameter("@css5",    MySqlDbType.VarChar,  20),
                new MySqlParameter("@csd1",    MySqlDbType.Int32,    11),
                new MySqlParameter("@csd2",    MySqlDbType.Int32,    11),
                new MySqlParameter("@csd3",    MySqlDbType.Int32,    11),
                new MySqlParameter("@csd4",    MySqlDbType.Int32,    11),
                new MySqlParameter("@csd5",    MySqlDbType.Int32,    11),
                new MySqlParameter("@csdc1",   MySqlDbType.Decimal,  20),
                new MySqlParameter("@csdc2",   MySqlDbType.Decimal,  20),
                new MySqlParameter("@csdc3",   MySqlDbType.Decimal,  20),
                new MySqlParameter("@csdc4",   MySqlDbType.Decimal,  20),
                new MySqlParameter("@csdc5",   MySqlDbType.Decimal,  20),
                new MySqlParameter("@id",      MySqlDbType.Int32, 11)
            };
            parameters[0].Value  = model.cname;
            parameters[1].Value  = model.ccode;
            parameters[2].Value  = model.cphone;
            parameters[3].Value  = model.cemail;
            parameters[4].Value  = model.clevel;
            parameters[5].Value  = model.csum;
            parameters[6].Value  = model.csex;
            parameters[7].Value  = model.cremark;
            parameters[8].Value  = model.css1;
            parameters[9].Value  = model.css2;
            parameters[10].Value = model.css3;
            parameters[11].Value = model.css4;
            parameters[12].Value = model.css5;
            parameters[13].Value = model.csd1;
            parameters[14].Value = model.csd2;
            parameters[15].Value = model.csd3;
            parameters[16].Value = model.csd4;
            parameters[17].Value = model.csd5;
            parameters[18].Value = model.csdc1;
            parameters[19].Value = model.csdc2;
            parameters[20].Value = model.csdc3;
            parameters[21].Value = model.csdc4;
            parameters[22].Value = model.csdc5;
            parameters[23].Value = model.id;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtcname.Text.Trim().Length == 0)
            {
                strErr += "cname不能为空!\\n";
            }
            if (this.txtccode.Text.Trim().Length == 0)
            {
                strErr += "ccode不能为空!\\n";
            }
            if (this.txtcphone.Text.Trim().Length == 0)
            {
                strErr += "cphone不能为空!\\n";
            }
            //if(this.txtcemail.Text.Trim().Length==0)
            //{
            //	strErr+="cemail不能为空!\\n";
            //}
            if (this.txtclevel.Text.Trim().Length == 0)
            {
                strErr += "clevel不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtcsum.Text) && !PageValidate.IsDecimal(txtcsum.Text))
            {
                strErr += "csum格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtcsex.Text))
            {
                strErr += "csex格式错误!\\n";
            }
            if (this.txtcremark.Text.Trim().Length == 0)
            {
                strErr += "cremark不能为空!\\n";
            }

            /*
             *          if(this.txtcss1.Text.Trim().Length==0)
             *          {
             *                  strErr+="css1不能为空!\\n";
             *          }
             *          if(this.txtcss2.Text.Trim().Length==0)
             *          {
             *                  strErr+="css2不能为空!\\n";
             *          }
             *          if(this.txtcss3.Text.Trim().Length==0)
             *          {
             *                  strErr+="css3不能为空!\\n";
             *          }
             *          if(this.txtcss4.Text.Trim().Length==0)
             *          {
             *                  strErr+="css4不能为空!\\n";
             *          }
             *          if(this.txtcss5.Text.Trim().Length==0)
             *          {
             *                  strErr+="css5不能为空!\\n";
             *          }
             *          if(!PageValidate.IsNumber(txtcsd1.Text))
             *          {
             *                  strErr+="csd1格式错误!\\n";
             *          }
             *          if(!PageValidate.IsNumber(txtcsd2.Text))
             *          {
             *                  strErr+="csd2格式错误!\\n";
             *          }
             *          if(!PageValidate.IsNumber(txtcsd3.Text))
             *          {
             *                  strErr+="csd3格式错误!\\n";
             *          }
             *          if(!PageValidate.IsNumber(txtcsd4.Text))
             *          {
             *                  strErr+="csd4格式错误!\\n";
             *          }
             *          if(!PageValidate.IsNumber(txtcsd5.Text))
             *          {
             *                  strErr+="csd5格式错误!\\n";
             *          }
             *          if(!PageValidate.IsDecimal(txtcsdc1.Text))
             *          {
             *                  strErr+="csdc1格式错误!\\n";
             *          }
             *          if(!PageValidate.IsDecimal(txtcsdc2.Text))
             *          {
             *                  strErr+="csdc2格式错误!\\n";
             *          }
             *          if(!PageValidate.IsDecimal(txtcsdc3.Text))
             *          {
             *                  strErr+="csdc3格式错误!\\n";
             *          }
             *          if(!PageValidate.IsDecimal(txtcsdc4.Text))
             *          {
             *                  strErr+="csdc4格式错误!\\n";
             *          }
             *          if(!PageValidate.IsDecimal(txtcsdc5.Text))
             *          {
             *                  strErr+="csdc5格式错误!\\n";
             *          }
             */

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string  cname   = this.txtcname.Text;
            string  ccode   = this.txtccode.Text;
            string  cphone  = this.txtcphone.Text;
            string  cemail  = this.txtcemail.Text;
            string  clevel  = this.txtclevel.Text;
            decimal csum    = decimal.Parse(this.txtcsum.Text);
            int     csex    = int.Parse(this.txtcsex.Text);
            string  cremark = this.txtcremark.Text;

            //string css1=this.txtcss1.Text;
            //string css2=this.txtcss2.Text;
            //string css3=this.txtcss3.Text;
            //string css4=this.txtcss4.Text;
            //string css5=this.txtcss5.Text;
            //int csd1=int.Parse(this.txtcsd1.Text);
            //int csd2=int.Parse(this.txtcsd2.Text);
            //int csd3=int.Parse(this.txtcsd3.Text);
            //int csd4=int.Parse(this.txtcsd4.Text);
            //int csd5=int.Parse(this.txtcsd5.Text);
            //decimal csdc1=decimal.Parse(this.txtcsdc1.Text);
            //decimal csdc2=decimal.Parse(this.txtcsdc2.Text);
            //decimal csdc3=decimal.Parse(this.txtcsdc3.Text);
            //decimal csdc4=decimal.Parse(this.txtcsdc4.Text);
            //decimal csdc5=decimal.Parse(this.txtcsdc5.Text);

            Jium.Model.consumer model = new Jium.Model.consumer();
            model.cname   = cname;
            model.ccode   = ccode;
            model.cphone  = cphone;
            model.cemail  = cemail;
            model.clevel  = clevel;
            model.csum    = csum;
            model.csex    = csex;
            model.cremark = cremark;
            model.csd1    = 5;
            model.csd5    = 5;
            //model.css1=css1;
            //model.css2=css2;
            //model.css3=css3;
            //model.css4=css4;
            //model.css5=css5;
            //model.csd1=csd1;
            //model.csd2=csd2;
            //model.csd3=csd3;
            //model.csd4=csd4;
            //model.csd5=csd5;
            //model.csdc1=csdc1;
            //model.csdc2=csdc2;
            //model.csdc3=csdc3;
            //model.csdc4=csdc4;
            //model.csdc5=csdc5;

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