public bool AddBom(BomVO VO) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = new SqlConnection(this.ConnectionString); cmd.CommandText = "AddBom"; cmd.CommandType = CommandType.StoredProcedure; if (VO.bom_parent_id == null) { cmd.Parameters.AddWithValue("@bom_parent_id", DBNull.Value); } else { cmd.Parameters.AddWithValue("@bom_parent_id", VO.bom_parent_id); } cmd.Parameters.AddWithValue("@product_id", VO.product_id); cmd.Parameters.AddWithValue("@bom_use_count", VO.bom_use_count); cmd.Parameters.AddWithValue("@bom_sdate", VO.bom_sdate); cmd.Parameters.AddWithValue("@bom_edate", VO.bom_edate); cmd.Parameters.AddWithValue("@bom_yn", VO.bom_yn); cmd.Parameters.AddWithValue("@plan_yn", VO.plan_yn); cmd.Parameters.AddWithValue("@bom_comment", VO.bom_comment); //cmd.Parameters.AddWithValue("@bom_uadmin", VO.bom_uadmin); cmd.Parameters.AddWithValue("@bom_udate", VO.bom_udate); cmd.Connection.Open(); var successRow = cmd.ExecuteNonQuery(); cmd.Connection.Close(); return(successRow > 0); } }
public BomPop(EditMode edit, BomVO vo = null) { InitializeComponent(); if (edit == EditMode.Insert) { this.Text = "BOM 등록"; this.edit = EditMode.Insert; } else if (edit == EditMode.Update) { this.Text = "BOM 수정"; this.edit = EditMode.Update; this.vo = vo; } }
private void btnUpdate_Click(object sender, EventArgs e) { //ProductVO product_vo = new ProductVO(); BomVO vo = new BomVO(); foreach (DataGridViewRow row in this.dgvBom.SelectedRows) { vo = row.DataBoundItem as BomVO; } BomPop frm = new BomPop(BomPop.EditMode.Update, vo); if (frm.ShowDialog() == DialogResult.OK) { bom_service = new BomService(); List <BomVO> newBOMlist = bom_service.GetBomAll(); //등록후 다시 조회 dgvBom.DataSource = newBOMlist; dgvBom.ClearSelection(); SetBottomStatusLabel("BOM 수정이 완료되었습니다."); } }
public bool UpdateBOM(BomVO VO) { BomDac dac = new BomDac(); return(dac.UpdateBOM(VO)); }
/// <summary> /// Bom 신규 추가 /// </summary> /// <returns></returns> public bool AddBom(BomVO vo) { BomDac dac = new BomDac(); return(dac.AddBom(vo)); }
private void btnRegister_Click(object sender, EventArgs e) { List <object> NullCheck = new List <object>(); bool ShowMessage = false; bool IsAllNull = true; foreach (DataGridViewRow row in dgv.Rows) { DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)dgv[0, row.Index]; // 체크 상태가 아닌 경우 if (chk.Value == null) { NullCheck.Add(chk.Value); // null일때 list에 추가 continue; } NullCheck.Add(chk.Value); // null가 아닐 때 값 list 추가 BomVO InsertData = new BomVO { Product_ID = dgv[1, row.Index].Value.ToInt(), Product_Group_Name = dgv[2, row.Index].Value.ToString(), Product_Name = dgv[3, row.Index].Value.ToString(), Product_Information = dgv[4, row.Index].Value.ToString(), Bom_Use_Quantity = 1 }; // 체크 상태인 경우 if ((bool)chk.Value == true) { bool check = false; if (dgv2.Rows.Count == 0 && BomEnrollCheck == false) { CheckedList.Add(InsertData); continue; } // 왼쪽 오른쪽 중복 체크 foreach (DataGridViewRow row1 in dgv2.Rows) { if (InsertData.Product_ID == dgv2[1, row1.Index].Value.ToInt()) { check = true; ShowMessage = true; } } if (check == false) { CheckedList.Add(InsertData); } } } foreach (object row in NullCheck) { if (row != null) { IsAllNull = false; } } if (IsAllNull == false) { dgv2.DataSource = null; dgv2.DataSource = CheckedList; } if (ShowMessage == true) { MessageBox.Show("이미 등록한 제품입니다."); } // dgv 갱신 // 첫번째 그리드 뷰에 대한 모든 체크박스 없앰 foreach (DataGridViewRow row in dgv.Rows) { dgv[0, row.Index].Value = null; } }
private void dgvBomDetail_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { foreach (DataGridViewRow row in this.dgvBomDetail.SelectedRows) { BomVO vo = new BomVO(); vo = row.DataBoundItem as BomVO; if (vo.bom_typevalue == "RM") { BomPop frm = new BomPop(BomPop.EditMode.Update, vo); if (frm.ShowDialog() == DialogResult.OK) { bom_service = new BomService(); List <BomVO> newBOMlist = bom_service.GetBomAll(); //등록후 다시 조회 dgvBom.DataSource = newBOMlist; dgvBom.ClearSelection(); SetBottomStatusLabel("BOM 수정이 완료되었습니다."); } SetBottomStatusLabel("원자재는 선택할 수 없습니다."); return; } } int product_id = Convert.ToInt32(dgvBomDetail[15, dgvBomDetail.CurrentRow.Index].Value); bom_service = new BomService(); List <BomVO> newBom = bom_service.GetBomAll(0, product_id); dgvBom.DataSource = null; dgvBom.Columns.Clear(); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "품목유형", "bom_type", true, 130, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "품목", "bom_codename", true, 150, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "품명", "bom_parent_name", true, 220); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "단위", "bom_unit", true, 100, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "사용여부", "bom_yn", true, 100, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "소요계획", "plan_yn", true, 100, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "시작일", "bom_sdate", true, 130, DataGridViewContentAlignment.MiddleRight); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "종료일", "bom_edate", true, 130, DataGridViewContentAlignment.MiddleRight); //GridViewUtil.AddNewColumnToDataGridView(dgvBom, "수정자", "bom_uadmin", true, 130, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "수정일", "bom_udate", true, 130, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "비고", "bom_comment", true, 150, DataGridViewContentAlignment.MiddleLeft); #region visible_false GridViewUtil.AddNewColumnToDataGridView(dgvBom, "품번", "product_id", false, 100, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "BOM레벨", "bom_level", false, 80, DataGridViewContentAlignment.MiddleRight); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "소요량", "bom_use_count", false, 80, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "BomID", "bom_id", false, 100, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBom, "상위품목", "bom_parent_id", false, 130); #endregion dgvBom.AutoGenerateColumns = false; dgvBom.DataSource = newBom; dgvBom.ClearSelection(); int bom_id = Convert.ToInt32(dgvBomDetail[15, dgvBomDetail.CurrentRow.Index].Value); List <BomVO> newBomDetail = bom_service.GetBomAll(0, bom_id); dgvBomDetail.DataSource = null; dgvBomDetail.Columns.Clear(); dgvBomDetail.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvBomDetail.Columns.Add("Number", "No."); dgvBomDetail.Columns[0].Width = 53; dgvBomDetail.Columns[0].Visible = false; GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "상위품목", "bom_parent_name", true, 130); GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "품목", "bom_codename", true, 130); GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "품명", "bom_name", true, 220); GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "품목유형", "bom_type", true, 130); GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "단위", "bom_unit", true, 78, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "소요량", "bom_use_count", true, 80, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "BOM레벨", "bom_level", true, 100, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "시작일", "bom_sdate", true, 130, DataGridViewContentAlignment.MiddleRight); GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "종료일", "bom_edate", true, 130, DataGridViewContentAlignment.MiddleRight); GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "사용여부", "bom_yn", true, 120, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "소요계획", "plan_yn", true, 120, DataGridViewContentAlignment.MiddleCenter); //GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "수정자", "bom_uadmin", true, 130, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "수정일", "bom_udate", true, 130, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "비고", "bom_comment", true, 130, DataGridViewContentAlignment.MiddleCenter); #region visible_false GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "품번", "product_id", false, 100, DataGridViewContentAlignment.MiddleCenter); GridViewUtil.AddNewColumnToDataGridView(dgvBomDetail, "BomID", "bom_id", false, 100, DataGridViewContentAlignment.MiddleCenter); #endregion dgvBomDetail.AutoGenerateColumns = false; dgvBomDetail.DataSource = newBomDetail; dgvBomDetail.ClearSelection(); SetBottomStatusLabel("BOM을 선택하세요"); }
private void btnSave_Click(object sender, EventArgs e) { if (edit == EditMode.Insert) //신규등록 { if (MessageBox.Show("등록하시겠습니까?", "신규등록", MessageBoxButtons.YesNo) == DialogResult.Yes) { bom_service = new BomService(); BomVO vo = new BomVO(); if (cboParentProduct.SelectedIndex == 0) { vo.bom_parent_id = null; } else { vo.bom_parent_id = cboParentProduct.SelectedValue.ToString(); } vo.product_id = Convert.ToInt32(cboProduct.SelectedValue); vo.bom_use_count = Convert.ToInt32(txtUseCount.Text.Trim()); vo.bom_sdate = dtpStartDate.Value.ToString("yyyy-MM-dd"); vo.bom_edate = dtpEndDate.Value.ToString("yyyy-MM-dd"); vo.bom_yn = cboIsUsed.SelectedValue.ToString(); vo.plan_yn = cboRequiredPlan.SelectedValue.ToString(); vo.bom_comment = txtNote.Text; //vo.bom_uadmin = txtModifier.Text; vo.bom_udate = txtModifyDate.Text; bool bResult = bom_service.AddBom(vo); if (bResult) { MessageBox.Show("등록성공"); this.Close(); } else { MessageBox.Show("등록실패 , 다시시도 하세요"); return; } } } else if (edit == EditMode.Update) //수정 { if (MessageBox.Show("수정하시겠습니까?", "품목수정", MessageBoxButtons.YesNo) == DialogResult.Yes) { bom_service = new BomService(); BomVO vo = new BomVO(); if (cboParentProduct.SelectedIndex == 0) { vo.bom_parent_id = null; } else { vo.bom_parent_id = (cboParentProduct.SelectedValue == null) ? "" : cboParentProduct.SelectedValue.ToString(); } vo.bom_id = this.vo.bom_id; vo.product_id = Convert.ToInt32(cboProduct.SelectedValue); vo.bom_use_count = Convert.ToInt32(txtUseCount.Text.Trim()); vo.bom_sdate = dtpStartDate.Value.ToString("yyyy-MM-dd"); vo.bom_edate = dtpEndDate.Value.ToString("yyyy-MM-dd"); vo.bom_yn = cboIsUsed.SelectedValue.ToString(); vo.plan_yn = cboRequiredPlan.SelectedValue.ToString(); vo.bom_comment = txtNote.Text; //vo.bom_uadmin = txtModifier.Text; vo.bom_udate = txtModifyDate.Text; bool bResult = bom_service.UpdateBOM(vo); if (bResult) { MessageBox.Show("수정성공"); this.Close(); } else { MessageBox.Show("수정실패 , 다시시도 하세요"); return; } } } }