private void frmMRT_Load(object sender, EventArgs e) { try { Material objMat = new Material(); DataTable dt = new DataTable(); objDepartment = objDepDL.GetByDepType("RPD"); bindItemList.DataSource = null; objMRMaterialCollec.Clear(); cmbStore.DataSource = objStoreDL.Get(); cmbBatchID.DataSource = objRPDBatch_DL.GetDataViewByState(RPDBatch.RPDBatchStatus.Approved, RPDBatch.RPDBatchStatus.Started, true); dt = objMaterialDL.GetDataView(MaterialCat); objSourceMaterial.DataSource = dt; cmbItem.DataSource = objSourceMaterial; objMat = objMaterialDL.Get(cmbItem.SelectedValue.ToString()); if (objMat != null) { lblUnit.Text = objMat.MatUnit.UnitCode; } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void frmMRT_Load(object sender, EventArgs e) { try { Material objMat = new Material(); DataTable dt = new DataTable(); bindItemList.DataSource = null; objMRMaterialCollec.Clear(); objStore = objStoreDL.Get("Packing"); txtStore.Text = objStore.StoreName; dt = objMaterialDL.GetDataView("Packing"); objSourceMaterial.DataSource = dt; cmbItem.DataSource = objSourceMaterial; objMat = objMaterialDL.Get(cmbItem.SelectedValue.ToString()); if (objMat != null) { lblUnit.Text = objMat.MatUnit.UnitCode; } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cmbMRType_SelectedIndexChanged(object sender, EventArgs e) { Material objMat = new Material(); BasicProduct objBasic = new BasicProduct(); FinishProduct objFinish = new FinishProduct(); bindItemList.DataSource = null; objMRFinishhProductCollec.Clear(); objMRMaterialCollec.Clear(); objMRBasicProductCollec.Clear(); try { if (cmbMRType.SelectedItem.Equals("Material")) { cmbItem.DataSource = objMaterialDL.GetDataView(); cmbItem.DisplayMember = "Material"; cmbItem.ValueMember = "MaterialCode"; objMat = objMaterialDL.Get(cmbItem.SelectedValue.ToString()); if (objMat != null) { lblUnit.Text = objMat.MatUnit.UnitCode; } } else if (cmbMRType.SelectedItem.Equals("Basic Products")) { cmbItem.DataSource = objBasicProductDL.GetDataView(true); cmbItem.DisplayMember = "Code"; cmbItem.ValueMember = "BasicProductCode"; objBasic = objBasicProductDL.Get(cmbItem.SelectedValue.ToString()); if (objBasic != null) { lblUnit.Text = objBasic.BasicProductUnit.UnitCode; } } else if (cmbMRType.SelectedItem.Equals("Finish Products")) { cmbItem.DataSource = objFinishProductDL.GetDataView(1); cmbItem.DisplayMember = "Code"; cmbItem.ValueMember = "FinishProductCode"; objFinish = objFinishProductDL.Get(cmbItem.SelectedValue.ToString()); if (objFinish != null) { lblUnit.Text = objFinish.FinishProductPackingType.PackingTitle; } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnMaterialAdd_Click(object sender, EventArgs e) { FormulaMaterial objFormulaMat = new FormulaMaterial(); try { if (cmbMaterials.Items.Count > 0) { objFormulaMat.Material = objMaterialDL.Get(cmbMaterials.SelectedValue.ToString()); objFormulaMat.Formula = objFormula; objFormulaMat.FormulaProductQty = Convert.ToDecimal(txtMaterialQty.Text); objFormulaMat.FormulaPart = cmbMaterialPart.Text.ToString(); objFormulaMaterialDL.Add(objFormulaMat, CurrentUser.UserEmp); bindMaterialList.DataSource = objFormulaMaterialDL.GetDataView_FormulaID(objFormula.FormulaID); bindItemList.DataSource = objFormulaDL.GetDataView_Items(objFormula.FormulaID); } } catch (FormatException fex) { MessageBox.Show(this, "Quantity should be a Numaric value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { objFormulaMat = null; } }
private void cmbItem_SelectedIndexChanged(object sender, EventArgs e) { txtGRNUnitCost.Text = "0.00"; cmbGRNNO.Text = ""; txtAvailableQty.Text = "0.00"; txtStockHoldingCost.Text = "0.00"; txtGRNQty.Text = "0.00"; Material objMat = new Material(); BasicProduct objBasic = new BasicProduct(); FinishProduct objFinish = new FinishProduct(); Store objStore = new Store(); try { String ItemCode = ""; txtUnit.Text = ""; if (cmbItem.Items.Count > 0 && cmbItem.SelectedValue != null) { ItemCode = cmbItem.SelectedValue.ToString(); } if (cmbStoreFrom.Items.Count > 0) { objStore = (Store)cmbStoreFrom.SelectedItem; } if (!ItemCode.Equals("")) { if (cmbMTNType.SelectedItem.Equals("Material")) { cmbGRNNO.DataSource = objGRNDL.Get_GEN_BY_Material(ItemCode, objStore.StoreID); objMat = objMaterialDL.Get(ItemCode); txtUnit.Text = objMat.MatUnit.UnitName; } else if (cmbMTNType.SelectedItem.Equals("Basic Product")) { cmbGRNNO.DataSource = objGRNDL.Get_GEN_BY_BasicProduct(ItemCode, objStore.StoreID); objBasic = objBasicProductDL.Get(ItemCode); txtUnit.Text = objBasic.BasicProductUnit.UnitName; } else if (cmbMTNType.SelectedItem.Equals("Finish Product")) { cmbGRNNO.DataSource = objGRNDL.Get_GEN_BY_FinishProduct(ItemCode, objStore.StoreID); objFinish = objFinishProductDL.Get(ItemCode); txtUnit.Text = objFinish.FinishProductPackingType.PackingTitle; } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cmbMaterials_SelectedIndexChanged(object sender, EventArgs e) { try { Material objMaterial = new Material(); objMaterial = objMaterial_DL.Get(cmbMaterials.SelectedValue.ToString()); lblUnit.Text = objMaterial.MatUnit.UnitCode; } catch (Exception ex) { } }
private void btnAddMaterial_Click(object sender, EventArgs e) { try { if (Convert.ToDecimal(txtMaterialQty.Text) <= 0) { MessageBox.Show(this, "Invalid Quantity", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { String OriginalMaterilCode = ""; if (objRPDBatchProduction != null) { OriginalMaterilCode = objRPDBatchProduction.Material.MaterialCode; } else { objRPDBatchProduction = new RPDBatchProduction(); } objRPDBatchProduction.Material = objMaterialDL.Get(cmbMaterialInter.SelectedValue.ToString()); objRPDBatchProduction.MaterialQuantity = Convert.ToDecimal(txtMaterialQty.Text); objRPDBatchProduction.RPDBatch = objRPDBatch; int res = objRPDBatchProductionDL.Add(objRPDBatchProduction, OriginalMaterilCode); if (res > 0) { ClearProduction(); gvProduction.AutoGenerateColumns = false; bindProduction.DataSource = objRPDBatchProductionDL.GetDataByBatchID(objRPDBatch.RPDBatchID); gvProduction.DataSource = bindProduction; bindProduction.ResetBindings(true); } } } catch (SqlException sqlex) { if (sqlex.Number == 2627) { MessageBox.Show(this, "Selected material already added", "Duplicate Data", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(this, "SQL error occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception) { MessageBox.Show(this, "Error occured while saving production details", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void cmbItem_SelectedIndexChanged(object sender, EventArgs e) { //txtGRNUnitCost.Text = "0.0"; // cmbGRNNO.Text = ""; Material objMat = new Material(); BasicProduct objBasic = new BasicProduct(); FinishProduct objFinish = new FinishProduct(); Store objStore = new Store(); Stock_DL objStockDL = new Stock_DL(ConnectionStringClass.GetConnection()); try { String ItemCode = ""; txtUnit.Text = ""; txtAvailableQty.Text = ""; if (cmbItem.Items.Count > 0 && cmbItem.SelectedValue != null) { ItemCode = cmbItem.SelectedValue.ToString(); objStore = (Store)cmbStoreFrom.SelectedItem; if (cmbMTNType.SelectedItem.Equals("Material")) { objMat = objMaterialDL.Get(ItemCode); txtUnit.Text = objMat.MatUnit.UnitName; //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_Material(objStore.StoreID, ItemCode).ToString(); txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.Material).ToString(); } else if (cmbMTNType.SelectedItem.Equals("Basic Product")) { objBasic = objBasicProductDL.Get(ItemCode); txtUnit.Text = objBasic.BasicProductUnit.UnitName; //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_BasicProduct(objStore.StoreID, ItemCode).ToString(); txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.BasicProduct).ToString(); } else if (cmbMTNType.SelectedItem.Equals("Finish Product")) { objFinish = objFinishProductDL.Get(ItemCode); txtUnit.Text = objFinish.FinishProductPackingType.PackingTitle; //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_FinishProduct(objStore.StoreID, ItemCode).ToString(); txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.FinishProduct).ToString(); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void txtmat_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Down) { gvMaterials.Focus(); } else if (e.KeyCode == Keys.Escape) { this.Close(); } else if (e.KeyCode == Keys.Enter) { try { e.Handled = true; Material_DL objMatDL = new Material_DL(ConnectionStringClass.GetConnection()); Material = objMatDL.Get(gvMaterials.SelectedRows[0].Cells["Column1"].Value.ToString()); this.Close(); } catch (Exception) { MessageBox.Show(this, "Error Occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception) { MessageBox.Show(this, "Error occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void cmbMRNO_SelectedIndexChanged(object sender, EventArgs e) { try { BatchPackingMR obj = new BatchPackingMR(); MRMaterial objMRMaterial = new MRMaterial(); Material objMaterial = new Material(); obj = objBatchPackingMR_DL.Get(Convert.ToInt64(cmbMRNO.SelectedValue)); objMaterial = objMaterial_DL.Get(obj.MaterialCode); lblUnit1.Text = objMaterial.MatUnit.UnitCode; lblUnit2.Text = objMaterial.MatUnit.UnitCode; lblUnit3.Text = objMaterial.MatUnit.UnitCode; txtQunatityReceived.Text = obj.StartQty.ToString(); // txtDamagedQty.Text = obj.BatchDamaged.ToString(); // txtBatchReturned.Text = obj.BatchReturned.ToString(); // txtBatchUsed.Text = obj.BatchUsed.ToString(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void cmbMaterial_SelectedIndexChanged(object sender, EventArgs e) { try { objMaterial = objMaterial_DL.Get(cmbMaterial.SelectedValue.ToString()); lblUnit1.Text = objMaterial.MatUnit.UnitCode; lblUnit2.Text = objMaterial.MatUnit.UnitCode; lblUnit3.Text = objMaterial.MatUnit.UnitCode; lblUnit4.Text = objMaterial.MatUnit.UnitCode; DataTable dtStock = new DataTable(); dtStock = objBatchPackingMR_DL.GetStock(ProductCode, cmbMaterial.SelectedValue.ToString()); if (dtStock.Rows.Count > 0) { txtSectionStock.Text = dtStock.Rows[0]["StockQty"].ToString(); } else { txtSectionStock.Text = "0"; } Load_MRList(); cmbMRNO.DisplayMember = "MRNO"; cmbMRNO.ValueMember = "ID"; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void cmMaterial_SelectedIndexChanged(object sender, EventArgs e) { try { if (cmMaterial.SelectedValue != null) { objMaterial = objMaterial_DL.Get(cmMaterial.SelectedValue.ToString()); txtMaterialCode.Text = cmMaterial.SelectedValue.ToString(); lblUnit1.Text = objMaterial.MatUnit.UnitCode; lblUnit2.Text = objMaterial.MatUnit.UnitCode; lblUnit3.Text = objMaterial.MatUnit.UnitCode; LoadStock(); Load_BinCard(); } else { Clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void gvMaterials_CellClick(object sender, DataGridViewCellEventArgs e) { try { Material_DL objMatDL = new Material_DL(ConnectionStringClass.GetConnection()); Material = objMatDL.Get(gvMaterials.Rows[e.RowIndex].Cells["Column1"].Value.ToString()); this.Close(); } catch (Exception) { MessageBox.Show(this, "Error Occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void gvMaterials_KeyUp(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter) { try { Material_DL objMatDL = new Material_DL(ConnectionStringClass.GetConnection()); Material = objMatDL.Get(gvMaterials.SelectedRows[0].Cells["Column1"].Value.ToString()); this.Close(); } catch (Exception) { MessageBox.Show(this, "Error Occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void txtMaterial_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { frmMaterialSelection objForm = new frmMaterialSelection("Packing"); objForm.ShowDialog(this); objMaterial = objMaterial_DL.Get(objForm.SelectedItemCode); txtMaterial.Text = objMaterial.MaterialDescription; txtMaterialCode.Text = objMaterial.MaterialCode; txtQuantity.Select(); lblUnit.Text = objMaterial.MatUnit.UnitCode; } }
private void btnAdd_Click(object sender, EventArgs e) { if (rdbMaterial.Checked == true) { MRMaterial obj = new MRMaterial(); bool duplicate = false; obj.Material = objMaterialDL.Get(dgvItemList.CurrentRow.Cells["ItemCode"].Value.ToString()); obj.ReqdQty = Convert.ToDecimal(dgvItemList.CurrentRow.Cells["ReqQty"].Value); obj.IssuedQty = 0; obj.Description = "Batch Material Requisition"; obj.MRBINNo = "N/A"; obj.MaterialCode = obj.Material.MaterialCode; obj.MaterialName = obj.Material.MaterialDescription; foreach (MRMaterial _obj in objMRMaterialCollec) { if (_obj.MaterialCode == obj.MaterialCode) { duplicate = true; break; } } for (int i = 0; i < dgvItemRequested.Rows.Count; i++) { if (dgvItemRequested.Rows[i].Cells["MaterialCode"].Value.ToString() == obj.MaterialCode) { duplicate = true; break; } } if (duplicate == false) { objMRMaterialCollec.Add(obj); } dgvItem_toRequest.AutoGenerateColumns = false; objSourceItems_toRequest.DataSource = objMRMaterialCollec; dgvItem_toRequest.DataSource = objSourceItems_toRequest; objSourceItems_toRequest.ResetBindings(true); } else { MRBasicProduct obj = new MRBasicProduct(); obj.BasicProduct = objBasicProductDL.Get(dgvItemList.CurrentRow.Cells["ItemCode"].Value.ToString()); obj.ReqdQty = Convert.ToDecimal(dgvItemList.CurrentRow.Cells["ReqQty"].Value); obj.ItemCode = obj.BasicProduct.BasicProductCode; obj.Item = obj.BasicProduct.BasicProductDescription; obj.Description = "No"; obj.MRBINNo = "No"; objMRBasicProductCollec.Add(obj); dgvItem_toRequest_BP.AutoGenerateColumns = false; objSourceItems_toRequest.DataSource = objMRBasicProductCollec; dgvItem_toRequest_BP.DataSource = objSourceItems_toRequest; objSourceItems_toRequest.ResetBindings(true); } }
private void btnGRN_Click(object sender, EventArgs e) { DialogResult TheResult = MessageBox.Show(this, "Have you Finished Entering Details", "Confirmation", MessageBoxButtons.YesNo); if (TheResult == System.Windows.Forms.DialogResult.Yes) { int count = 0; bool CanRaiseGRN = false; foreach (DataGridViewRow dgr in dgvItemList.Rows) { if (Convert.ToBoolean(dgr.Cells["Select"].Value) == true) { count = count + 1; } if (Convert.ToDecimal(dgr.Cells["Quantity"].Value) > 0) { if (Convert.ToDecimal(dgr.Cells["UnitPrice"].Value) > 0) { CanRaiseGRN = true; } else { if (Convert.ToBoolean(dgr.Cells["Select"].Value) == true) { MessageBox.Show(this, "There are some Unit Price With Zeros which is Not allowed", "Error", MessageBoxButtons.OK); } } } else { if (Convert.ToBoolean(dgr.Cells["Select"].Value) == true) { if (Convert.ToDecimal(dgr.Cells["Quantity"].Value) + Convert.ToDecimal(dgr.Cells["RejectQty"].Value) == Convert.ToDecimal(dgr.Cells["TGRNQuantity"].Value)) { DeliverNoteMaterials obj = new DeliverNoteMaterials(); obj = objDeliverNoteMaterials_DL.Get(Convert.ToInt64(dgr.Cells["ID"].Value)); objDeliverNoteMaterials_DL.Update(obj); Clear(); } else { break; } } } } if ((count > 0) && (CanRaiseGRN == true)) { GRN objGRN = new GRN(); objGRN.GRNEnterdBy = CurrentUser.EmployeeID; objGRN.GRNStore = objStore; objGRN.GRNType = GRN.Type.Material; objGRN.GRNStatus = GRN.Status.Initial; objGRN.GRNCategory = 0; int newGRNNO = objGRNDL.Add_Direct_TGRN(objGRN, txtDeliverNote.Text, txtPONo.Text); objGRN.GRNNo = newGRNNO; foreach (DataGridViewRow dgr in dgvItemList.Rows) { if (Convert.ToBoolean(dgr.Cells["Select"].Value) == true) { if (Convert.ToDecimal(dgr.Cells["Quantity"].Value) > 0) { if (Convert.ToDecimal(dgr.Cells["UnitPrice"].Value) > 0) { objGRNMaterials.GRN = objGRN; objGRNMaterials.Material = objMaterialDL.Get(Convert.ToString(dgr.Cells["MaterialCode"].Value)); objGRNMaterials.GrossQty = Convert.ToDecimal(dgr.Cells["Quantity"].Value); objGRNMaterials.NetQty = Convert.ToDecimal(dgr.Cells["Quantity"].Value); objGRNMaterials.UnitPrice = Convert.ToDecimal(dgr.Cells["UnitPrice"].Value); objGRNMaterials.Remarks = "No"; objGRNMaterialsDL.Add_FromDeliverNote(objGRNMaterials, txtDeliverNote.Text); } } } } MessageBox.Show(this, "Sucessfully GRN : GRNNO " + newGRNNO.ToString(), "Successful", MessageBoxButtons.OK); Clear(); } } }
private void btnSave_Click(object sender, EventArgs e) { PRPDBatch objPRPDBatch = new PRPDBatch(); DialogResult dr = MessageBox.Show(this, "Are you sure you want to Create a PRPD Batch?\n\nThis will Create a new PRPD Batch and send to approval\nClick Yes to Create", "Confirmation ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (dr == DialogResult.Yes) { if (cmbMaterial.SelectedValue == null) { MessageBox.Show(this, "Please select a material", "Empty Fields", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtNewBatchQuantity.Text.Equals("")) { MessageBox.Show(this, "Please enter a Quantity", "Empty Fields", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Convert.ToDecimal(txtNewBatchQuantity.Text) <= 0) { MessageBox.Show(this, "Please enter a valid Quantity", "Invalid Data", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { try { objPRPDBatch.PRPDBatchInstructedBy = CurrentUser.UserEmp; objPRPDBatch.PRPDBatchInstructedDate = DateTime.Today; objPRPDBatch.PRPDBatchMaterial = objMaterial_DL.Get(cmbMaterial.SelectedValue.ToString()); objPRPDBatch.PRPDBatchQty = Convert.ToDecimal(txtNewBatchQuantity.Text); objPRPDBatch.MRIN = 0; objPRPDBatch.Status = PRPDBatch.PRPDBatchStatus.Created; if (rdbPP.Checked == true) { objPRPDBatch.Type = PRPDBatch.PRPDType.PrimaryPreperation; } else if (rdbPPOutsource.Checked == true) { objPRPDBatch.Type = PRPDBatch.PRPDType.PrimaryOutsource; } else { objPRPDBatch.Type = PRPDBatch.PRPDType.Rework; } objPRPDBatch.PRPDBatchComments = "N/A"; String PRPDID = objPRPDBatch_DL.AddPP(objPRPDBatch); if (PRPDID != null) { objPRPDBatch.PRPDBatchID = PRPDID; foreach (PRPDBatchActivityInstructions _obj in objPRPDBatchActivityInstructionsCollec) { _obj.PRPDBatch = objPRPDBatch; objPRPDBatchActivityInstructions_DL.Add(_obj); } //long res = GenerateMR(objPRPDBatch); //int x = 0; //if (res > 0) //{ // objPRPDBatch.MRIN = res; // x = objPRPDBatch_DL.UpdateMR(objPRPDBatch.PRPDBatchID, res); //} //if (x > 0) //{ MessageBox.Show(this, "Successfully Created a PRPD Batch \n\nPRPD Batch ID :- " + PRPDID, "Successfull Created", MessageBoxButtons.OK, MessageBoxIcon.Information); frmPRPDBatchCreatePreperation objFrm = new frmPRPDBatchCreatePreperation(CurrentUser); objFrm.MdiParent = this.MdiParent; this.Close(); objFrm.Show(); //} //else //{ // objPRPDBatch_DL.Delete(PRPDID); // MessageBox.Show(this, "Error occuerd while saving, PRPD batch does not save", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); //} } else { MessageBox.Show(this, "Error occuerd while saving, PRPD batch does not save", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(this, "Error occuerd while saving,Please check the enterd data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void btnItemAdd_Click(object sender, EventArgs e) { if (txtQty.Text.Equals("")) { MessageBox.Show(this, "Please fill the quantity field", "Empty Field", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { bool ItemList = false; MRMaterial objMRMat = new MRMaterial(); try { if (ItemSelect) { objMRMat.Description = txtDescription.Text; objMRMat.Material = objMaterialDL.Get(cmbItem.SelectedValue.ToString()); objMRMat.ReqdQty = Convert.ToDecimal(txtQty.Text); objMRMat.MRBINNo = "N/A"; if (objMRMaterial.Material.MaterialCode != objMRMat.Material.MaterialCode) { foreach (MRMaterial obj in objMRMaterialCollec) { if (obj.Material.MaterialCode == objMRMat.Material.MaterialCode) { MessageBox.Show(this, "This item already in the list,Please Select the item from List and Update", "Item in the List", MessageBoxButtons.OK, MessageBoxIcon.Information); ItemList = true; break; } } if (!ItemList) { objMRMaterialCollec.Delete(objMRMaterial); objMRMaterialCollec.Add(objMRMat); ClearItem(); } } else { objMRMaterialCollec.Delete(objMRMaterial); objMRMaterialCollec.Add(objMRMat); ClearItem(); } bindItemList.DataSource = objMRMaterialCollec; bindItemList.ResetBindings(false); } else { objMRMat.Description = txtDescription.Text; objMRMat.Material = objMaterialDL.Get(cmbItem.SelectedValue.ToString()); objMRMat.ReqdQty = Convert.ToDecimal(txtQty.Text); objMRMat.MRBINNo = "N/A"; if (objMRMaterialCollec.Count > 0) { foreach (MRMaterial obj in objMRMaterialCollec) { if (obj.Material.MaterialCode == objMRMat.Material.MaterialCode) { MessageBox.Show(this, "This item already in the list,Please Select the item from List and Update", "Item in the List", MessageBoxButtons.OK, MessageBoxIcon.Information); ItemList = true; break; } } if (!ItemList) { objMRMaterialCollec.Add(objMRMat); ClearItem(); } } else { objMRMaterialCollec.Add(objMRMat); ClearItem(); } bindItemList.DataSource = objMRMaterialCollec; bindItemList.ResetBindings(false); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { objMRMat = null; } } }
private void gvMaterialList_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex >= 0) { cmbFromMonth.SelectedIndex = 0; cmbToMonth.SelectedIndex = 0; String Code = gvMaterialList.Rows[e.RowIndex].Cells["ColMaterialCode"].Value.ToString(); objSelectedMaterial = objMaterialDL.Get(Code); cmbMaterialType.SelectedValue = objSelectedMaterial.MateialType.MatType.ToString(); cmbMainType.SelectedItem = objSelectedMaterial.MaterialMainType; if (objSelectedMaterial.MaterialMainType.Equals("Intermediate")) { //rbIntermediate.Checked = true; //IntermediateMaterialSelect = true; txtMaterialCode.Text = objSelectedMaterial.MaterialCode; txtmaterialName.Text = objSelectedMaterial.MaterialDescription; txtAcgUnitCost.Text = objSelectedMaterial.MatCost.ToString(); txtMaterialQtyPerUnit.Text = objSelectedMaterial.MatBasicQty.ToString(); txtMaterialBasicPartialSize.Text = objSelectedMaterial.MatParticleSize.ToString(); cmbMaterialBasicMaterial.SelectedValue = objSelectedMaterial.MatBasicMaterial; cmbMaterialBasicMaterial.ValueMember = "MaterialCode"; cmbMaterialBasicMaterial.DisplayMember = "Material"; } else { //rbBasic.Checked = true; //IntermediateMaterialSelect = false; txtMaterialCode.Text = objSelectedMaterial.MaterialCode; txtmaterialName.Text = objSelectedMaterial.MaterialDescription; txtAcgUnitCost.Text = objSelectedMaterial.MatCost.ToString(); cbMaterialImport.Checked = objSelectedMaterial.IsExport; cbMaterialLocal.Checked = objSelectedMaterial.IsLocal; cbMaterialSeasonal.Checked = objSelectedMaterial.IsSeasanal; cmbFromMonth.SelectedItem = objSelectedMaterial.MatSeasonFrom; cmbToMonth.SelectedItem = objSelectedMaterial.MatSeasonTo; cmbMainType.SelectedItem = objSelectedMaterial.MaterialMainType; cmbMaterialBasicMaterial.SelectedValue = objSelectedMaterial.MatBasicMaterial; cmbMaterialBasicMaterial.ValueMember = "MaterialCode"; cmbMaterialBasicMaterial.DisplayMember = "Material"; txtMaterialQtyPerUnit.Text = objSelectedMaterial.MatBasicQty.ToString(); if (objSelectedMaterial.MaterialType == "Dry") { rdbDry.Checked = true; } if (objSelectedMaterial.MaterialType == "Green") { rdbGreen.Checked = true; } } cmbMaterialUnit.SelectedValue = objSelectedMaterial.MatUnit.UnitID.ToString(); cmbMaterialForm.SelectedValue = objSelectedMaterial.MatForm.FormID.ToString(); this.MaterialSelect = true; } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSave_Click(object sender, EventArgs e) { Material objMaterial = new Material(); GRNMaterials objGRNMaterialsTemp = new GRNMaterials(); bool ItemInList = false; try { if (txtNetQty.Text.Equals("") || txtUnitCost.Text.Equals("")) { MessageBox.Show(this, "Please Fill all fields", "Empty Fields", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (txtNetQty.Text != "0") { if (ItemSelect) { objGRNMaterialsCollec.Delete(objGRNMaterials); } objMaterial = objMaterialDL.Get(cmbItem.SelectedValue.ToString()); objGRNMaterialsTemp.Material = objMaterial; objGRNMaterialsTemp.GrossQty = Convert.ToDecimal(txtNetQty.Text); objGRNMaterialsTemp.NetQty = Convert.ToDecimal(txtNetQty.Text); objGRNMaterialsTemp.Remarks = "N/A"; objGRNMaterialsTemp.UnitPrice = Convert.ToDecimal(txtUnitCost.Text); foreach (GRNMaterials obj in objGRNMaterialsCollec) { if (obj.Material.MaterialCode == objMaterial.MaterialCode) { MessageBox.Show(this, "This item already added to the list, You can't add same item repeatedly to a GRN. If you want GRN same item again Please create a another GRN", "Item already Added", MessageBoxButtons.OK, MessageBoxIcon.Information); ItemInList = true; break; } } if (!ItemInList) { objGRNMaterialsCollec.Add(objGRNMaterialsTemp); bindItemList.DataSource = objGRNMaterialsCollec; ClearItem(); } ItemInList = false; bindItemList.ResetBindings(false); ItemInList = false; bindItemList.ResetBindings(false); } } } catch (FormatException fex) { MessageBox.Show(this, fex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { objMaterial = null; } }