public MRBasicProductCollec Get(long MRNO) { try { SqlParameter[] paramList = new SqlParameter[] { new SqlParameter("@MRNO", MRNO) }; DataTable dt = Execute.RunSP_DataTable(Connection, "SPGET_MRBasicProduct_By_MR", paramList); MRBasicProductCollec objMRBasicCollec = new MRBasicProductCollec(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { MRBasicProduct objMRBasicProduct = new MRBasicProduct(); objMRBasicProduct.BasicProduct = objBasicProduct_DL.Get(Convert.ToString(dt.Rows[i]["MRMaterialCode"])); objMRBasicProduct.Description = Convert.ToString(dt.Rows[i]["MRDescription"]); objMRBasicProduct.MR = objMR_DL.Get(Convert.ToInt64(dt.Rows[i]["MRNO"])); objMRBasicProduct.MRBINNo = Convert.ToString(dt.Rows[i]["MRBINNo"]); objMRBasicProduct.ReqdQty = Convert.ToDecimal(dt.Rows[i]["MRReqdQty"]); objMRBasicProduct.IssuedQty = Convert.ToDecimal(dt.Rows[i]["MRIssuedQty"]); objMRBasicProduct.UnitCode = objMRBasicProduct.BasicProduct.BasicProductUnit.UnitCode; objMRBasicProduct.Item = objMRBasicProduct.BasicProduct.BasicProductCode + " - " + objMRBasicProduct.BasicProduct.BasicProductDescription; objMRBasicProduct.ItemCode = objMRBasicProduct.BasicProduct.BasicProductCode; if (dt.Rows[i]["MRUnitRate"] != null) { objMRBasicProduct.UniRate = Convert.ToDecimal(dt.Rows[i]["MRUnitRate"]); } else { objMRBasicProduct.UniRate = 0; } objMRBasicCollec.Add(objMRBasicProduct); } } return(objMRBasicCollec); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public MRBasicProductCollec Get() { try { DataTable dt = Execute.RunSP_DataTable(Connection, "SPGET_MRBasicProduct"); MRBasicProductCollec objMRBasicCollec = new MRBasicProductCollec(); for (int i = 0; i < dt.Rows.Count; i++) { MRBasicProduct objMRBasicProduct = new MRBasicProduct(); objMRBasicProduct.BasicProduct = objBasicProduct_DL.Get(Convert.ToString(dt.Rows[i]["MRBasicProductID"])); objMRBasicProduct.Description = Convert.ToString(dt.Rows[i]["MRDescription"]); objMRBasicProduct.MR = objMR_DL.Get(Convert.ToInt64(dt.Rows[i]["MRNO"])); objMRBasicProduct.MRBINNo = Convert.ToString(dt.Rows[i]["MRBINNo"]); objMRBasicProduct.ReqdQty = Convert.ToDecimal(dt.Rows[i]["MRReqdQty"]); objMRBasicProduct.IssuedQty = Convert.ToDecimal(dt.Rows[i]["MRIssuedQty"]); if (dt.Rows[i]["MRUnitRate"] != null) { objMRBasicProduct.UniRate = Convert.ToDecimal(dt.Rows[i]["MRUnitRate"]); } else { objMRBasicProduct.UniRate = 0; } objMRBasicCollec.Add(objMRBasicProduct); } return(objMRBasicCollec); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
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; MRBasicProduct objMRBasic = new MRBasicProduct(); try { if (ItemSelect) { objMRBasic.Description = txtDescription.Text; objMRBasic.BasicProduct = objBasicProduct_DL.Get(cmbItem.SelectedValue.ToString()); objMRBasic.ReqdQty = Convert.ToDecimal(txtQty.Text); objMRBasic.MRBINNo = "N/A"; objMRBasic.Item = objMRBasic.BasicProduct.BasicProductCode + "-" + objMRBasic.BasicProduct.BasicProductDescription; objMRBasic.ItemCode = objMRBasic.BasicProduct.BasicProductCode; if (objMRBasicProduct.BasicProduct.BasicProductCode != objMRBasic.BasicProduct.BasicProductCode) { foreach (MRBasicProduct obj in objMRBasicProductCollec) { if (objMRBasicProduct.BasicProduct.BasicProductCode == objMRBasic.BasicProduct.BasicProductCode) { 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) { objMRBasicProductCollec.Delete(objMRBasicProduct); objMRBasicProductCollec.Add(objMRBasic); ClearItem(); } } else { objMRBasicProductCollec.Delete(objMRBasicProduct); objMRBasicProductCollec.Add(objMRBasic); ClearItem(); } bindItemList.DataSource = objMRBasicProductCollec; bindItemList.ResetBindings(false); } else { objMRBasic.Description = txtDescription.Text; objMRBasic.BasicProduct = objBasicProduct_DL.Get(cmbItem.SelectedValue.ToString()); objMRBasic.ReqdQty = Convert.ToDecimal(txtQty.Text); objMRBasic.MRBINNo = "N/A"; objMRBasic.Item = objMRBasic.BasicProduct.BasicProductCode + "-" + objMRBasic.BasicProduct.BasicProductDescription; objMRBasic.ItemCode = objMRBasic.BasicProduct.BasicProductCode; objMRBasic.UnitCode = objMRBasic.BasicProduct.BasicProductUnit.UnitCode; if (objMRBasicProductCollec.Count > 0) { foreach (MRBasicProduct obj in objMRBasicProductCollec) { if (obj.BasicProduct.BasicProductCode == objMRBasic.BasicProduct.BasicProductCode) { 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) { objMRBasicProductCollec.Add(objMRBasic); ClearItem(); } } else { objMRBasicProductCollec.Add(objMRBasic); ClearItem(); } bindItemList.DataSource = objMRBasicProductCollec; bindItemList.ResetBindings(false); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { objMRBasic = null; } } }
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); } }