Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.parts model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into parts(");
            strSql.Append("PN,Barcode,gongdan,componentId,remark)");
            strSql.Append(" values (");
            strSql.Append("@PN,@Barcode,@gongdan,@componentId,@remark)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@PN",          MySqlDbType.VarChar, 64),
                new MySqlParameter("@Barcode",     MySqlDbType.VarChar, 64),
                new MySqlParameter("@gongdan",     MySqlDbType.VarChar, 64),
                new MySqlParameter("@componentId", MySqlDbType.Int32,   11),
                new MySqlParameter("@remark",      MySqlDbType.VarChar, 64)
            };
            parameters[0].Value = model.PN;
            parameters[1].Value = model.Barcode;
            parameters[2].Value = model.gongdan;
            parameters[3].Value = model.componentId;
            parameters[4].Value = model.remark;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public void dealwithcomp(object lingjianhao)
        {
            string lj_num = lingjianhao.ToString();

            // 目前架构这样, 就不用联合查询了。 宁可多查询一部
            #region 获得零件id
            Maticsoft.BLL.parts          parts_bll  = new Maticsoft.BLL.parts();
            List <Maticsoft.Model.parts> parts_objs = parts_bll.GetModelList(string.Format(" PN = {0} ", lj_num));
            if (parts_objs.Count == 1)
            {
                Maticsoft.Model.parts part_obj = parts_objs[0];
                this.comp_type = Convert.ToInt32(part_obj.componentId);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("未知零件类型");
                this.Close();
            }
            #endregion

            #region 获得零件名字
            Maticsoft.BLL.component   comp_bll  = new Maticsoft.BLL.component();
            Maticsoft.Model.component comp_mode = comp_bll.GetModel(comp_type);
            if (comp_mode != null)
            {
                this.comp_name = comp_mode.name;
                this.mode      = comp_mode.sm;
            }
            // System.Windows.Forms.MessageBox.Show(string.Format("comp_type : == {0}, comp_name : === {1}", this.comp_type, this.comp_name));
            #endregion
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.parts DataRowToModel(DataRow row)
 {
     Maticsoft.Model.parts model = new Maticsoft.Model.parts();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["PN"] != null)
         {
             model.PN = row["PN"].ToString();
         }
         if (row["Barcode"] != null)
         {
             model.Barcode = row["Barcode"].ToString();
         }
         if (row["gongdan"] != null)
         {
             model.gongdan = row["gongdan"].ToString();
         }
         if (row["componentId"] != null && row["componentId"].ToString() != "")
         {
             model.componentId = int.Parse(row["componentId"].ToString());
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtPN.Text.Trim().Length == 0)
            {
                strErr += "PN不能为空!\\n";
            }
            if (this.txtname.Text.Trim().Length == 0)
            {
                strErr += "name不能为空!\\n";
            }
            if (this.txtjobnum.Text.Trim().Length == 0)
            {
                strErr += "jobnum不能为空!\\n";
            }
            if (this.txtARef.Text.Trim().Length == 0)
            {
                strErr += "ARef不能为空!\\n";
            }
            if (this.txtsize.Text.Trim().Length == 0)
            {
                strErr += "size不能为空!\\n";
            }
            if (this.txtsm.Text.Trim().Length == 0)
            {
                strErr += "sm不能为空!\\n";
            }
            if (this.txtBarcode.Text.Trim().Length == 0)
            {
                strErr += "Barcode不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string PN      = this.txtPN.Text;
            string name    = this.txtname.Text;
            string jobnum  = this.txtjobnum.Text;
            string ARef    = this.txtARef.Text;
            string size    = this.txtsize.Text;
            string sm      = this.txtsm.Text;
            string Barcode = this.txtBarcode.Text;

            Maticsoft.Model.parts model = new Maticsoft.Model.parts();
            model.PN      = PN;
            model.name    = name;
            model.jobnum  = jobnum;
            model.ARef    = ARef;
            model.size    = size;
            model.sm      = sm;
            model.Barcode = Barcode;

            Maticsoft.BLL.parts bll = new Maticsoft.BLL.parts();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Ejemplo n.º 5
0
 private void ShowInfo(int id)
 {
     Maticsoft.BLL.parts   bll   = new Maticsoft.BLL.parts();
     Maticsoft.Model.parts model = bll.GetModel(id);
     this.lblid.Text      = model.id.ToString();
     this.txtPN.Text      = model.PN;
     this.txtname.Text    = model.name;
     this.txtjobnum.Text  = model.jobnum;
     this.txtARef.Text    = model.ARef;
     this.txtsize.Text    = model.size;
     this.txtsm.Text      = model.sm;
     this.txtBarcode.Text = model.Barcode;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.parts model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update parts set ");
            strSql.Append("PN=@PN,");
            strSql.Append("name=@name,");
            strSql.Append("jobnum=@jobnum,");
            strSql.Append("ARef=@ARef,");
            strSql.Append("size=@size,");
            strSql.Append("sm=@sm,");
            strSql.Append("Barcode=@Barcode");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@PN",      MySqlDbType.VarChar, 64),
                new MySqlParameter("@name",    MySqlDbType.VarChar, 64),
                new MySqlParameter("@jobnum",  MySqlDbType.VarChar, 64),
                new MySqlParameter("@ARef",    MySqlDbType.VarChar, 64),
                new MySqlParameter("@size",    MySqlDbType.Double,  64),
                new MySqlParameter("@sm",      MySqlDbType.VarChar, 64),
                new MySqlParameter("@Barcode", MySqlDbType.VarChar, 64),
                new MySqlParameter("@id",      MySqlDbType.Int32, 64)
            };
            parameters[0].Value = model.PN;
            parameters[1].Value = model.name;
            parameters[2].Value = model.jobnum;
            parameters[3].Value = model.ARef;
            parameters[4].Value = model.size;
            parameters[5].Value = model.sm;
            parameters[6].Value = model.Barcode;
            parameters[7].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.parts model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update parts set ");
            strSql.Append("PN=@PN,");
            strSql.Append("Barcode=@Barcode,");
            strSql.Append("gongdan=@gongdan,");
            strSql.Append("componentId=@componentId,");
            strSql.Append("remark=@remark");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@PN",          MySqlDbType.VarChar, 64),
                new MySqlParameter("@Barcode",     MySqlDbType.VarChar, 64),
                new MySqlParameter("@gongdan",     MySqlDbType.VarChar, 64),
                new MySqlParameter("@componentId", MySqlDbType.Int32,   11),
                new MySqlParameter("@remark",      MySqlDbType.VarChar, 64),
                new MySqlParameter("@id",          MySqlDbType.Int32, 64)
            };
            parameters[0].Value = model.PN;
            parameters[1].Value = model.Barcode;
            parameters[2].Value = model.gongdan;
            parameters[3].Value = model.componentId;
            parameters[4].Value = model.remark;
            parameters[5].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.parts model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into parts(");
            strSql.Append("PN,name,jobnum,ARef,size,sm,Barcode)");
            strSql.Append(" values (");
            strSql.Append("@PN,@name,@jobnum,@ARef,@size,@sm,@Barcode)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@PN",      MySqlDbType.VarChar, 64),
                new MySqlParameter("@name",    MySqlDbType.VarChar, 64),
                new MySqlParameter("@jobnum",  MySqlDbType.VarChar, 64),
                new MySqlParameter("@ARef",    MySqlDbType.VarChar, 64),
                new MySqlParameter("@size",    MySqlDbType.Double,  64),
                new MySqlParameter("@sm",      MySqlDbType.VarChar, 64),
                new MySqlParameter("@Barcode", MySqlDbType.VarChar, 64)
            };
            parameters[0].Value = model.PN;
            parameters[1].Value = model.name;
            parameters[2].Value = model.jobnum;
            parameters[3].Value = model.ARef;
            parameters[4].Value = model.size;
            parameters[5].Value = model.sm;
            parameters[6].Value = model.Barcode;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.parts DataRowToModel(DataRow row)
 {
     Maticsoft.Model.parts model = new Maticsoft.Model.parts();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["PN"] != null)
         {
             model.PN = row["PN"].ToString();
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
         if (row["jobnum"] != null)
         {
             model.jobnum = row["jobnum"].ToString();
         }
         if (row["ARef"] != null)
         {
             model.ARef = row["ARef"].ToString();
         }
         //model.size=row["size"].ToString();
         if (row["sm"] != null)
         {
             model.sm = row["sm"].ToString();
         }
         if (row["Barcode"] != null)
         {
             model.Barcode = row["Barcode"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 10
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.parts GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,PN,name,jobnum,ARef,size,sm,Barcode from parts ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox_ljh.Text == "")
                {
                    MessageBox.Show("零件号为空");
                    return;
                }
                if (textBox_lxm.Text == "")
                {
                    MessageBox.Show("序列号为空");
                    return;
                }
                if (textbox_gongdan.Text == "")
                {
                    MessageBox.Show("工单号为空");
                    return;
                }
                if (comboBox1.SelectedIndex < 0)
                {
                    MessageBox.Show("请选择正确的类型");
                    return;
                }

                Maticsoft.BLL.parts          part_bll   = new Maticsoft.BLL.parts();
                List <Maticsoft.Model.parts> parts_list = part_bll.GetModelList(string.Format(" PN = '{0}'", textBox_ljh.Text));
                if (parts_list.Count > 0)
                {
                    Maticsoft.Model.parts parts_exmode = parts_list[0];
                    parts_exmode.Barcode     = textBox_lxm.Text;
                    parts_exmode.PN          = textBox_ljh.Text;
                    parts_exmode.remark      = "管理";
                    parts_exmode.gongdan     = textbox_gongdan.Text;
                    parts_exmode.componentId = this.comp_list[comboBox1.SelectedIndex].componentId;

                    if (part_bll.Update(parts_exmode))
                    {
                        MessageBox.Show("更新成功");
                    }
                    else
                    {
                        MessageBox.Show("更新失败");
                    }
                }
                else
                {
                    Maticsoft.Model.parts parts_mode = new Maticsoft.Model.parts()
                    {
                        Barcode     = textBox_lxm.Text,
                        PN          = textBox_ljh.Text,
                        remark      = "管理",
                        gongdan     = textbox_gongdan.Text,
                        componentId = this.comp_list[comboBox1.SelectedIndex].componentId,
                    };


                    if (part_bll.Add(parts_mode))
                    {
                        MessageBox.Show("添加成功");
                    }
                    else
                    {
                        MessageBox.Show("添加失败");
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
            finally
            {
                this.DialogResult = DialogResult.OK;
            }
        }