/// <summary> /// BOMID, 상위품목명, 품목명, 소요량, 레벨, 비고를 vo에 입력받아 DB의 내용을 수정한다. /// 작성자: 최현호 / 작성일: 210212 /// </summary> /// <param name="vo"></param> /// <returns></returns> public bool Update(BOMVO vo) { try { string sql = @"EXEC SP_UpdateBOM @bom_id, @prod_parent_name, @product_name, @bom_use_count, @bom_level, @bom_comment"; using (SqlCommand cmd = new SqlCommand(sql, conn)) { cmd.Parameters.AddWithValue("@bom_id", vo.bom_id); cmd.Parameters.AddWithValue("@prod_parent_name", vo.prod_parent_name); cmd.Parameters.AddWithValue("@product_name", vo.product_name); cmd.Parameters.AddWithValue("@bom_use_count", vo.bom_use_count); cmd.Parameters.AddWithValue("@bom_level", vo.bom_level); cmd.Parameters.AddWithValue("@bom_comment", vo.bom_comment); int iRowAffect = cmd.ExecuteNonQuery(); conn.Close(); return(iRowAffect > 0); } } catch (Exception) { throw; } }
/// <summary> /// 팝업폼 제목을 기준으로 등록인지 수정인지 판단 /// BOMVO에 내용들을 담아서 DAC단의 파라미터로 전달. /// 성공여부를 Bool 타입으로 받아서 결과 메세지 출력 /// 작성자: 최현호 / 작성일: 210210 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEdit_Click(object sender, EventArgs e) { try { #region 등록버튼 if (label1.Text == "BOM 등록") { BOMVO vo = new BOMVO { prod_parent_name = cbParent.Text, product_name = cbProd.Text, bom_use_count = (int)nuUseCount.Value, bom_level = (int)nuLevel.Value, bom_comment = txtComment.Text }; bool result = service.Insert(vo); if (result) { MessageBox.Show(Properties.Resources.msgOK); } else { MessageBox.Show(Properties.Resources.msgError); } } #endregion #region 수정버튼 else if (label1.Text == "BOM 수정") { BOMVO vo = new BOMVO { bom_id = int.Parse(lblBOMID.Text), prod_parent_name = cbParent.Text, product_name = cbProd.Text, bom_use_count = (int)nuUseCount.Value, bom_level = (int)nuLevel.Value, bom_comment = txtComment.Text }; bool result = service.Update(vo); if (result) { MessageBox.Show(Properties.Resources.msgOK); } else { MessageBox.Show(Properties.Resources.msgError); } } #endregion } catch (Exception err) { MessageBox.Show(err.Message); } }
private void InsertProduct() { //이미지를 Byte 배열로 변환 Cursor currentCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; string localFile = pictureBox1.Tag.ToString().Replace("\\", "/"); byte[] ImageData; FileStream fs = new FileStream(localFile, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); ImageData = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); ProductVO Pitem = new ProductVO { Product_Name = txtProductName.Text, Product_Price = Convert.ToInt32(txtProductMoney.Text.Replace(",", "").Replace("원", "")), Product_Category = cboProductCategory.SelectedValue.ToString(), Product_Origin = Convert.ToInt32(lblOrigin.Text.Replace(",", "").Replace("원", "")), Product_Image = ImageData }; List <BOMVO> citemList = new List <BOMVO>(); foreach (Control control in splitContainer2.Panel1.Controls) { if (control is SemiProductCompControl) { SemiProductCompControl spc = (SemiProductCompControl)control; BOMVO citem = new BOMVO { Combination_Product_ID = spc.TxtName.Tag.ToString(), Combination_RequiredQty = Convert.ToInt32(spc.Qty.Value) }; count += spc.Controls.Count; citemList.Add(citem); } } try { BOMService service = new BOMService(); service.InsertProduct(Pitem, citemList, count); } catch (Exception err) { Log.WriteError(err.Message, err); } }
public static void BOMProdName(ComboBox cbo, List <BOMVO> list, bool blankItem = true, string blankText = "") { var codeList = (from item in list select item).ToList(); if (blankItem) { BOMVO blank = new BOMVO { product_id = null, product_name = blankText }; codeList.Insert(0, blank); } cbo.DisplayMember = "product_name"; cbo.ValueMember = "product_id"; cbo.DataSource = codeList; }
//Product 테이블과 Combination 테이블 수정 private void UpdateSemiProduct() { ProductVO Pitem = new ProductVO { Product_ID = pCode, Product_Name = txtSemiproductName.Text, Product_Price = Convert.ToInt32(txtSemiproductMoney.Text.Replace(",", "").Replace("원", "")), Product_Safety = Convert.ToInt32(numSafety.Value), Warehouse_ID = Convert.ToInt32(cboWarehouse.SelectedValue), Product_Category = cboCategory.SelectedValue.ToString() }; List <BOMVO> citemList = new List <BOMVO>(); foreach (Control control in splitContainer2.Panel1.Controls) { if (control is SemiProductCompControl) { SemiProductCompControl spc = (SemiProductCompControl)control; BOMVO citem = new BOMVO { Combination_Product_ID = spc.TxtName.Tag.ToString(), Combination_RequiredQty = Convert.ToInt32(spc.Qty.Value) }; citemList.Add(citem); } } try { BOMService service = new BOMService(); service.UpdateSemiProduct(Pitem, citemList, splitContainer2.Panel1.Controls.Count); } catch (Exception err) { Log.WriteError(err.Message, err); } }
public bool Update(BOMVO vo) { BOMDAC dac = new BOMDAC(); return(dac.Update(vo)); }
public bool Insert(BOMVO vo) { BOMDAC dac = new BOMDAC(); return(dac.Insert(vo)); }