Ejemplo n.º 1
0
        /// <summary>
        /// 根据条件返回单个Cutlist对象
        /// </summary>
        /// <param name="whereSql"></param>
        /// <returns></returns>
        public DXFCutList GetDXFCutListByWhereSql(string whereSql)
        {
            string sql = "select CutListId,CategoryId,PartDescription,Length,Width,Thickness,Quantity,Materials,PartNo from DXFCutList";

            sql += whereSql;
            SqlDataReader objReader     = SQLHelper.GetReader(sql);
            DXFCutList    objDXFCutList = null;

            if (objReader.Read())
            {
                objDXFCutList = new DXFCutList()
                {
                    CutListId       = Convert.ToInt32(objReader["CutListId"]),
                    CategoryId      = Convert.ToInt32(objReader["CategoryId"]),
                    PartDescription = objReader["PartDescription"].ToString(),
                    Length          = Convert.ToDecimal(objReader["Length"].ToString()),
                    Width           = Convert.ToDecimal(objReader["Width"].ToString()),
                    Thickness       = Convert.ToDecimal(objReader["Thickness"].ToString()),
                    Quantity        = Convert.ToInt32(objReader["Quantity"]),
                    Materials       = objReader["Materials"].ToString(),
                    PartNo          = objReader["PartNo"].ToString()
                };
            }
            objReader.Close();
            return(objDXFCutList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加配件信息
        /// </summary>
        /// <param name="objDXFCutList"></param>
        /// <returns></returns>
        public bool AddDXFCutList(DXFCutList objDXFCutList)
        {
            string sql = "insert into DXFCutList (CategoryId,PartDescription,Length,Width,Thickness,Quantity,Materials,PartNo)";

            sql += " values({0},'{1}','{2}','{3}','{4}',{5},'{6}','{7}')";
            sql  = string.Format(sql, objDXFCutList.CategoryId, objDXFCutList.PartDescription, objDXFCutList.Length, objDXFCutList.Width,
                                 objDXFCutList.Thickness, objDXFCutList.Quantity, objDXFCutList.Materials, objDXFCutList.PartNo);
            try
            {
                SQLHelper.GetSingleResult(sql);
                return(true);
            }
            catch (SqlException ex)
            {
                //2627
                if (ex.Number == 2627)
                {
                    throw new Exception("信息重复,不能添加重复的项目信息");
                }
                else
                {
                    throw new Exception("添加配件信息时数据库访问异常" + ex.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 修改配件信息
        /// </summary>
        /// <param name="objDXFCutList"></param>
        /// <returns></returns>
        public int EditDXFCutList(DXFCutList objDXFCutList)
        {
            string sql = "update DXFCutList set CategoryId={0},PartDescription='{1}',Length='{2}',Width='{3}',";

            sql += "Thickness='{4}',Quantity={5},Materials='{6}',PartNo='{7}' where CutListId={8}";
            sql  = string.Format(sql, objDXFCutList.CategoryId, objDXFCutList.PartDescription, objDXFCutList.Length, objDXFCutList.Width,
                                 objDXFCutList.Thickness, objDXFCutList.Quantity, objDXFCutList.Materials, objDXFCutList.PartNo, objDXFCutList.CutListId);
            try
            {
                return(SQLHelper.Update(sql));
            }
            catch (SqlException ex)
            {
                throw new Exception("数据库操作出现异常:" + ex.Message);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        private void tsmiEditDXFCutList_Click(object sender, EventArgs e)
        {
            if (dgvDXFCutList.RowCount == 0)
            {
                return;
            }
            if (dgvDXFCutList.CurrentRow == null)
            {
                return;
            }
            string     id            = dgvDXFCutList.CurrentRow.Cells["CutListId"].Value.ToString();
            DXFCutList objDxfCutList = objDxfCutListService.GetDXFCutListById(id);

            cobCategoryId.Text      = objDxfCutList.CategoryId.ToString();
            txtPartDescription.Text = objDxfCutList.PartDescription;
            txtLength.Text          = objDxfCutList.Length.ToString();
            txtWidth.Text           = objDxfCutList.Width.ToString();
            txtThickness.Text       = objDxfCutList.Thickness.ToString();
            txtQuantity.Text        = objDxfCutList.Quantity.ToString();
            txtMaterials.Text       = objDxfCutList.Materials;
            txtPartNo.Text          = objDxfCutList.PartNo;
            btnDXFCutlist.Text      = "修改行";
            btnDXFCutlist.Tag       = id;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 添加和修改条目
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDXFCutlist_Click(object sender, EventArgs e)
        {
            #region 数据验证
            if (cobCategoryId.SelectedIndex == -1)
            {
                MessageBox.Show("请选择分类编号", "验证信息");
                cobCategoryId.Focus();
                return;
            }

            if (txtPartDescription.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入部件描述", "验证信息");
                txtPartDescription.Focus();
                return;
            }
            if (txtLength.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入长", "验证信息");
                txtLength.Focus();
                return;
            }
            if (txtWidth.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入宽", "验证信息");
                txtWidth.Focus();
                return;
            }
            if (txtThickness.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入厚度", "验证信息");
                txtThickness.Focus();
                return;
            }
            if (txtQuantity.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入数量", "验证信息");
                txtQuantity.Focus();
                return;
            }
            if (txtMaterials.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入材料", "验证信息");
                txtMaterials.Focus();
                return;
            }
            if (txtPartNo.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入零件号", "验证信息");
                txtPartNo.Focus();
                return;
            }
            #endregion

            if (btnDXFCutlist.Tag.Equals(0))
            {
                //提交添加
                //封装对象
                DXFCutList objDxfCutList = new DXFCutList()
                {
                    CategoryId      = Convert.ToInt32(cobCategoryId.Text),
                    PartDescription = txtPartDescription.Text.Trim(),
                    Length          = Convert.ToDecimal(txtLength.Text),
                    Width           = Convert.ToDecimal(txtWidth.Text),
                    Thickness       = Convert.ToDecimal(txtThickness.Text),
                    Quantity        = Convert.ToInt32(txtQuantity.Text),
                    Materials       = txtMaterials.Text.ToUpper(),
                    PartNo          = txtPartNo.Text.ToUpper()
                };
                //提交添加
                try
                {
                    if (objDxfCutListService.AddDXFCutList(objDxfCutList))
                    {
                        //提示添加成功
                        MessageBox.Show("配件信息添加成功", "提示信息");
                        //刷新显示
                        dgvDXFCutList.DataSource = objDxfCutListService.GetDXFCutListsByCategoryId(cobCategoryId.Text);
                        //清空内容
                        foreach (Control item in Controls)
                        {
                            if (item is TextBox)
                            {
                                item.Text = "";
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                //封装对象
                DXFCutList objDxfCutList = new DXFCutList()
                {
                    CutListId       = Convert.ToInt32(btnDXFCutlist.Tag),
                    CategoryId      = Convert.ToInt32(cobCategoryId.Text),
                    PartDescription = txtPartDescription.Text.Trim(),
                    Length          = Convert.ToDecimal(txtLength.Text),
                    Width           = Convert.ToDecimal(txtWidth.Text),
                    Thickness       = Convert.ToDecimal(txtThickness.Text),
                    Quantity        = Convert.ToInt32(txtQuantity.Text),
                    Materials       = txtMaterials.Text.ToUpper(),
                    PartNo          = txtPartNo.Text.ToUpper()
                };
                //提交修改
                //调用后台方法修改对象
                try
                {
                    if (objDxfCutListService.EditDXFCutList(objDxfCutList) == 1)
                    {
                        //提示添加成功
                        MessageBox.Show("配件信息修改成功", "提示信息");
                        //刷新显示
                        dgvDXFCutList.DataSource = objDxfCutListService.GetDXFCutListsByCategoryId(cobCategoryId.Text);
                        //清空内容
                        foreach (Control item in Controls)
                        {
                            if (item is TextBox)
                            {
                                item.Text = "";
                            }
                        }
                        btnDXFCutlist.Text = "添加行";
                        btnDXFCutlist.Tag  = 0;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }