Esempio n. 1
0
        public MRMaterialCollec Get(long MRNO)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@MRNO", MRNO)
                };


                DataTable dt = Execute.RunSP_DataTable(Connection, "SPGET_MRMaterial_By_MR", paramList);

                MRMaterialCollec objMRMaterialCollec = new MRMaterialCollec();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    MRMaterial objMRMaterial = new MRMaterial();

                    if (dt.Rows[i]["MRDescription"] != null)
                    {
                        objMRMaterial.Description = Convert.ToString(dt.Rows[i]["MRDescription"]);
                    }
                    if (dt.Rows[i]["MRMaterialCode"] != null)
                    {
                        objMRMaterial.Material = objMaterial_DL.Get(Convert.ToString(dt.Rows[i]["MRMaterialCode"]));
                    }

                    if (dt.Rows[i]["MRNO"] != null)
                    {
                        objMRMaterial.MR = objMR_DL.Get(Convert.ToInt64(dt.Rows[i]["MRNO"]));
                    }
                    objMRMaterial.MRBINNo   = Convert.ToString(dt.Rows[i]["MRBINNo"]);
                    objMRMaterial.ReqdQty   = Convert.ToDecimal(dt.Rows[i]["MRReqdQty"]);
                    objMRMaterial.IssuedQty = Convert.ToDecimal(dt.Rows[i]["MRIssuedQty"]);

                    if (dt.Rows[i]["MRUnitRate"] != null)
                    {
                        objMRMaterial.UniRate = Convert.ToDecimal(dt.Rows[i]["MRUnitRate"]);
                    }
                    else
                    {
                        objMRMaterial.UniRate = 0;
                    }

                    objMRMaterial.Item     = objMRMaterial.Material.MaterialCode + " - " + objMRMaterial.Material.MaterialDescription;
                    objMRMaterial.UnitCode = objMaterial_DL.Get(Convert.ToString(dt.Rows[i]["MRMaterialCode"])).MatUnit.UnitCode;

                    objMRMaterialCollec.Add(objMRMaterial);
                }
                return(objMRMaterialCollec);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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";
                        objMRMat.Item        = objMRMat.Material.MaterialCode + " - " + objMRMat.Material.MaterialDescription;
                        objMRMat.UnitCode    = objMRMat.Material.MatUnit.UnitCode;


                        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.Item        = objMRMat.Material.MaterialCode + " - " + objMRMat.Material.MaterialDescription;
                        objMRMat.UnitCode    = objMRMat.Material.MatUnit.UnitCode;

                        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;
                }
            }
        }