Example #1
0
        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());
            }
        }
Example #2
0
 private void gvItemList_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex >= 0)
         {
             if (cmbMRType.SelectedItem.Equals("Material"))
             {
                 objMRMaterial         = (MRMaterial)gvItemList.Rows[e.RowIndex].DataBoundItem;
                 txtDescription.Text   = objMRMaterial.Description;
                 txtQty.Text           = objMRMaterial.ReqdQty.ToString();
                 cmbItem.SelectedValue = objMRMaterial.Material.MaterialCode;
             }
             else if (cmbMRType.SelectedItem.Equals("Basic Products"))
             {
                 objMRBasicProduct     = (MRBasicProduct)gvItemList.Rows[e.RowIndex].DataBoundItem;
                 txtDescription.Text   = objMRBasicProduct.Description;
                 txtQty.Text           = objMRBasicProduct.ReqdQty.ToString();
                 cmbItem.SelectedValue = objMRBasicProduct.BasicProduct.BasicProductCode;
             }
             else if (cmbMRType.SelectedItem.Equals("Finish Products"))
             {
                 objMRFinishProduct   = (MRFinishProduct)gvItemList.Rows[e.RowIndex].DataBoundItem;
                 txtDescription.Text  = objMRFinishProduct.Description;
                 txtQty.Text          = objMRFinishProduct.ReqdQty.ToString();
                 cmbItem.SelectedItem = objMRFinishProduct.FinishProduct.FinishProductCode;
             }
             ItemSelect = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #3
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);
            }
        }
Example #4
0
        public long GenerateMR(PRPDBatch objPRPD)
        {
            MR objMR = new MR();
            MRMaterialCollec      objMRMatCollec           = new MRMaterialCollec();
            MRFinishProductCollec objMRFinishProductCollec = new MRFinishProductCollec();
            MRBasicProductCollec  objMRBasicProductCollec  = new MRBasicProductCollec();
            BatchMR       objBatchMR      = new BatchMR();
            Department_DL objDepDL        = new Department_DL(ConnectionStringClass.GetConnection());
            MR_DL         objMRDL         = new MR_DL(ConnectionStringClass.GetConnection());
            MRMaterial_DL objMRMaterialDL = new MRMaterial_DL(ConnectionStringClass.GetConnection());
            Store_DL      objStoreDL      = new Store_DL(ConnectionStringClass.GetConnection());

            try
            {
                objMR.MRDate           = DateTime.Now;
                objMR.MRDepartmentFrom = objDepDL.GetByDepType("PRPD");
                objMR.MREnterdBy       = CurrentUser.EmployeeID;
                objMR.MRStatus         = MR.Status.Initial;

                objMR.MRStore    = objStore;
                objMR.MRType     = MR.Type.Material;
                objMR.MRRemarks  = "Material Requition(Materials) for PRPD Batch NO " + objPRPD.PRPDBatchID.ToString();
                objMR.OriginType = MR.Origin.ToBatch;

                MRMaterial obj = new MRMaterial();
                obj.Description = "PRPD Batch Material Requition";
                obj.Material    = objPRPD.PRPDBatchMaterial;
                obj.MRBINNo     = "";
                obj.ReqdQty     = objPRPD.PRPDBatchQty;


                long MRNO = objMRDL.Add_M(objMR);
                if (MRNO > 0)
                {
                    objMR.MRNO = MRNO;
                    obj.MR     = objMR;
                    objMRMaterialDL.Add(obj);
                }
                return(MRNO);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Example #5
0
        public int Issue(MRMaterial obj, String StoreID)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@MRNO", obj.MR.MRNO),
                    new SqlParameter("@MRMaterialCode", obj.Material.MaterialCode),
                    new SqlParameter("@MRIssuedQty", obj.IssuedQty),
                    new SqlParameter("@StoreID", StoreID)
                };

                return(Execute.RunSP_RowsEffected(Connection, "SPUPDATE_MRMaterial_Issue", paramList));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Example #6
0
        private void gvItemList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex >= 0)
                {
                    objMRMaterial         = (MRMaterial)gvItemList.Rows[e.RowIndex].DataBoundItem;
                    txtDescription.Text   = objMRMaterial.Description;
                    txtQty.Text           = objMRMaterial.ReqdQty.ToString();
                    cmbItem.SelectedValue = objMRMaterial.Material.MaterialCode;

                    ItemSelect = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #7
0
        public MRMaterial Get(long MRNO, String MaterialCode)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@MRNO", MRNO),
                    new SqlParameter("@MaterialCode", MaterialCode)
                };


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

                MRMaterial objMRMaterial = new MRMaterial();

                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["MRDescription"] != null)
                    {
                        objMRMaterial.Description = Convert.ToString(dt.Rows[0]["MRDescription"]);
                    }
                    objMRMaterial.Material  = objMaterial_DL.Get(Convert.ToString(dt.Rows[0]["MRMaterialCode"]));
                    objMRMaterial.MR        = objMR_DL.Get(Convert.ToInt64(dt.Rows[0]["MRNO"]));
                    objMRMaterial.MRBINNo   = Convert.ToString(dt.Rows[0]["MRBINNo"]);
                    objMRMaterial.ReqdQty   = Convert.ToDecimal(dt.Rows[0]["MRReqdQty"]);
                    objMRMaterial.IssuedQty = Convert.ToDecimal(dt.Rows[0]["MRIssuedQty"]);

                    if (dt.Rows[0]["MRUnitRate"] != DBNull.Value)
                    {
                        objMRMaterial.UniRate = Convert.ToDecimal(dt.Rows[0]["MRUnitRate"]);
                    }
                    else
                    {
                        objMRMaterial.UniRate = 0;
                    }
                }
                return(objMRMaterial);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Example #8
0
        public int Add(MRMaterial obj)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@MRNO", obj.MR.MRNO),
                    new SqlParameter("@MRMaterialCode", obj.Material.MaterialCode),
                    new SqlParameter("@MRDescription", obj.Description),
                    new SqlParameter("@MRReqdQty", obj.ReqdQty),
                    new SqlParameter("@MRIssuedQty", obj.IssuedQty),
                    new SqlParameter("@MRBINNo", obj.MRBINNo)
                };

                return(Execute.RunSP_RowsEffected(Connection, "SPADD_MRMaterial", paramList));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Example #9
0
        public int Update(MRMaterial obj, long OriginalMRNO, String OriginalMaterialCode)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@MRNO", obj.MR.MRNO),
                    new SqlParameter("@MRMaterialCode", obj.Material.MaterialCode),
                    new SqlParameter("@MRDescription", obj.Description),
                    new SqlParameter("@MRReqdQty", obj.ReqdQty),
                    new SqlParameter("@MRIssuedQty", obj.IssuedQty),
                    new SqlParameter("@MRBINNo", obj.MRBINNo),
                    new SqlParameter("@Original_MRNO", OriginalMRNO),
                    new SqlParameter("@Original_MRFinishMaterialCode", OriginalMaterialCode)
                };

                return(Execute.RunSP_RowsEffected(Connection, "SPUPDATE_MRMaterial", paramList));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Example #10
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);
            }
        }
Example #11
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;
                }
            }
        }
Example #12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if ((txtFinalQty.Text != "") && (txtSampleSize.Text != "") && (txtImpurities.Text != ""))
            {
                try
                {
                    if (objQCReport_DL.IsPRPDBatchAccept(objPRPDBatch.PRPDBatchID, (int)QCReport.ReportStatus.Accept))
                    {
                        if (txtComments.Text == "")
                        {
                            objPRPDBatch.PRPDBatchComments = "N/A";
                        }
                        else
                        {
                            objPRPDBatch.PRPDBatchComments = txtComments.Text;
                        }

                        if (objPRPDBatch.Type == PRPDBatch.PRPDType.PrimaryOutsource)
                        {
                            objPRPDBatch.OutSourceQty = Convert.ToDecimal(txtOutsourceQty.Text);
                        }
                        else
                        {
                            objPRPDBatch.OutSourceQty = 0;
                        }
                        objPRPDBatch.PRPDBatchEndDate         = dtpDateHandOver.Value;
                        objPRPDBatch.PRPDBatchFinalQty        = Convert.ToDecimal(txtFinalQty.Text);
                        objPRPDBatch.PRPDBatchEndBy           = CurrentUser.UserEmp;
                        objPRPDBatch.PRPDBatchTotalImpurities = Convert.ToDecimal(txtImpurities.Text);
                        objPRPDBatch.PRPDSampleSize           = txtSampleSize.Text;
                        objPRPDBatch.Status = PRPDBatch.PRPDBatchStatus.Finished;

                        MRMaterial    objMRMaterial    = new MRMaterial();
                        MRMaterial_DL objMRMaterial_DL = new MRMaterial_DL(ConnectionStringClass.GetConnection());

                        objMRMaterial = objMRMaterial_DL.Get(objPRPDBatch.MRIN, objPRPDBatch.PRPDBatchMaterial.MaterialCode);

                        if ((objPRPDBatch.PRPDBatchFinalQty > 0) && (objMRMaterial.IssuedQty >= objPRPDBatch.PRPDBatchFinalQty))
                        {
                            if (objPRPDBatch.Type == PRPDBatch.PRPDType.PrimaryOutsource)
                            {
                                if (objPRPDBatch.OutSourceQty > 0)
                                {
                                    Decimal sampleQty = Convert.ToDecimal(objPRPDBatch.PRPDSampleSize);

                                    objPRPDBatch_DL.Update_Finish(objPRPDBatch);

                                    //Update Batch Cost

                                    objPRPDBatch_DL.Update_BatchCost(objPRPDBatch.PRPDBatchID, CurrentUser.EmployeeID, (int)objPRPDBatch.Type);

                                    Load_Batches(objDepartment);

                                    MessageBox.Show(this, "Successfully Saved and the Batch File is sent for Costing Approval", "Save Records", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                    if (cmbPRPDBatchID.Items.Count <= 0)
                                    {
                                        MessageBox.Show(this, "Approved Batch file list Empty", "No Approved Batch Files", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        this.Close();
                                    }
                                    else
                                    {
                                        cmbPRPDBatchID_SelectedIndexChanged(sender, e);
                                        grpFinalizeDetails.Enabled = false;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show(this, "Outsource Qty Need to be greater than Zero", "Invalid Qty", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                Decimal sampleQty = Convert.ToDecimal(objPRPDBatch.PRPDSampleSize);

                                objPRPDBatch_DL.Update_Finish(objPRPDBatch);

                                //Update Batch Cost

                                objPRPDBatch_DL.Update_BatchCost(objPRPDBatch.PRPDBatchID, CurrentUser.EmployeeID, (int)objPRPDBatch.Type);

                                Load_Batches(objDepartment);

                                MessageBox.Show(this, "Successfully Saved and the Batch File is sent for Costing Approval", "Save Records", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                if (cmbPRPDBatchID.Items.Count <= 0)
                                {
                                    MessageBox.Show(this, "Approved Batch file list Empty", "No Approved Batch Files", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    this.Close();
                                }
                                else
                                {
                                    cmbPRPDBatchID_SelectedIndexChanged(sender, e);
                                    grpFinalizeDetails.Enabled = false;
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show(this, "Invalid Final Quantity", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show(this, "PRPD Batch Quality test incomplete", "Quality Test", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "Error occured while finalizing", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show(this, "Please Fill All Fields", "Fill Records", MessageBoxButtons.OK);
            }
        }
Example #13
0
        private void cmbPRPDBatchID_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbPRPDBatchID.Items.Count != 0)
            {
                try
                {
                    bool IsStart = false;

                    objPRPDBatch = objPRPDBatch_DL.Get(cmbPRPDBatchID.SelectedValue.ToString());

                    gvActivity.AutoGenerateColumns = false;
                    bindActivities.DataSource      = objPRPDBatchActivity_DL.GetView(objPRPDBatch.PRPDBatchID);
                    gvActivity.DataSource          = bindActivities;
                    bindActivities.ResetBindings(true);

                    txtMaterial.Text = objPRPDBatch.PRPDBatchMaterial.MaterialCode + " - " + objPRPDBatch.PRPDBatchMaterial.MaterialDescription;

                    MR obj = new MR();
                    obj = objMR_DL.Get(objPRPDBatch.MRIN);

                    if (obj.MRStatus == MR.Status.Recevied)
                    {
                        IsStart = true;
                    }


                    MRMaterial_DL objMRMaterialDL = new MRMaterial_DL(ConnectionStringClass.GetConnection());
                    MRMaterial    objMRMat        = objMRMaterialDL.Get(objPRPDBatch.MRIN, objPRPDBatch.PRPDBatchMaterial.MaterialCode);

                    if (objMRMat.IssuedQty <= 0)
                    {
                        IsStart = false;
                    }


                    if (objPRPDBatch.Type == PRPDBatch.PRPDType.Rework)
                    {
                        lblTitle.Text       = "Rework - " + objPRPDBatch.PRPDBatchID;
                        txtNote.Text        = obj.MRNO.ToString() + " - " + obj.MRStatus.ToString();
                        txtReceivedQty.Text = objMRMaterialDL.Get(obj.MRNO, objPRPDBatch.PRPDBatchMaterial.MaterialCode).IssuedQty.ToString();
                        lblNote.Text        = "MRNO";
                        lblUnit4.Text       = objPRPDBatch.PRPDBatchMaterial.MatUnit.UnitCode;
                    }
                    else if (objPRPDBatch.Type == PRPDBatch.PRPDType.PrimaryOutsource)
                    {
                        lblTitle.Text       = "Primary Outsource - " + objPRPDBatch.PRPDBatchID;
                        txtNote.Text        = obj.MRNO.ToString() + " - " + obj.MRStatus.ToString();
                        txtReceivedQty.Text = objMRMaterialDL.Get(obj.MRNO, objPRPDBatch.PRPDBatchMaterial.MaterialCode).IssuedQty.ToString();
                        lblNote.Text        = "MRNO";
                        lblUnit4.Text       = objPRPDBatch.PRPDBatchMaterial.MatUnit.UnitCode;
                    }
                    else if (objPRPDBatch.Type == PRPDBatch.PRPDType.PrimaryPreperation)
                    {
                        lblTitle.Text = "Preperation - " + objPRPDBatch.PRPDBatchID;

                        txtNote.Text        = obj.MRNO.ToString() + " - " + obj.MRStatus.ToString();
                        txtReceivedQty.Text = objMRMaterialDL.Get(obj.MRNO, objPRPDBatch.PRPDBatchMaterial.MaterialCode).IssuedQty.ToString();
                        lblNote.Text        = "MRNO";
                        lblUnit4.Text       = objPRPDBatch.PRPDBatchMaterial.MatUnit.UnitCode;
                    }

                    if (IsStart)
                    {
                        btnStartBatch.Enabled          = true;
                        tbcPRPDBatchProduction.Enabled = true;

                        if (objPRPDBatch.Status == PRPDBatch.PRPDBatchStatus.Started)
                        {
                            tbcPRPDBatchProduction.Enabled = true;
                            btnStartBatch.Enabled          = false;

                            cmbSupervisedBy.Enabled = false;
                        }
                        else if (objPRPDBatch.Status == PRPDBatch.PRPDBatchStatus.Approved)
                        {
                            tbcPRPDBatchProduction.Enabled = false;
                            btnStartBatch.Enabled          = true;
                        }
                    }
                    else
                    {
                        btnStartBatch.Enabled          = false;
                        tbcPRPDBatchProduction.Enabled = false;
                    }



                    dtMainActtivity_PRPD = objMainActivity_DL.Get_Data_PRPD_Activity(objPRPDBatch.PRPDBatchID);

                    cmbActivity.DataSource = dtMainActtivity_PRPD;

                    if (dtMainActtivity_PRPD.Rows.Count != 0)
                    {
                        cmbActivity.SelectedIndex = 0;
                    }

                    objPRPDBatch = objPRPDBatch_DL.Get(cmbPRPDBatchID.SelectedValue.ToString());


                    txtMaterial.Text = objPRPDBatch.PRPDBatchMaterial.MaterialCode + " - " + objPRPDBatch.PRPDBatchMaterial.MaterialDescription;

                    txtInstructedBy.Text = objPRPDBatch.PRPDBatchInstructedBy.EmployeeName;
                    txtQuantity.Text     = objPRPDBatch.PRPDBatchQty.ToString();
                    dtpCreatedDate.Value = objPRPDBatch.PRPDBatchInstructedDate;

                    //Load Instructions

                    dtPRPDBatchActivityInstructions = objPRPDBatchActivityInstructions_DL.GetDataByBatchID(cmbPRPDBatchID.SelectedValue.ToString());

                    objSourceActInstructions.DataSource = dtPRPDBatchActivityInstructions;

                    dgvActivityInstructions.AutoGenerateColumns = false;
                    dgvActivityInstructions.DataSource          = objSourceActInstructions;
                    objSourceActInstructions.ResetBindings(true);


                    txtBatchState.Text     = Enum.GetName(typeof(PRPDBatch.PRPDBatchStatus), objPRPDBatch.Status).ToString();
                    lblUnit.Text           = objPRPDBatch.PRPDBatchMaterial.MatUnit.UnitCode;
                    bindReports.DataSource = objQCReport_DL.GetView_PRPD(objPRPDBatch.PRPDBatchID);
                    if (objQCReport_DL.IsPRPDBatchAccept(objPRPDBatch.PRPDBatchID, (int)QCReport.ReportStatus.Accept))
                    {
                        grpFinalizeDetails.Enabled = true;
                    }
                    else
                    {
                        grpFinalizeDetails.Enabled = false;
                    }

                    lblUnit1.Text        = objPRPDBatch.PRPDBatchMaterial.MatUnit.UnitCode;
                    lblUnit2.Text        = objPRPDBatch.PRPDBatchMaterial.MatUnit.UnitCode;
                    lblUnit3.Text        = objPRPDBatch.PRPDBatchMaterial.MatUnit.UnitCode;
                    lblUnitSample.Text   = objPRPDBatch.PRPDBatchMaterial.MatUnit.UnitCode;
                    txtOutsourceQty.Text = "0";


                    //Load Reports

                    Load_Reports();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "Error occured while loading", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Example #14
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult dresutl = MessageBox.Show(this, "Are you sure you want to Issue Items for selected Material Requsition?\n\nClick Yes to Issue", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (dresutl == DialogResult.Yes)
                {
                    if (cmbStore.Items.Count > 0)
                    {
                        Store objStore = (Store)cmbStore.SelectedItem;
                        if (this.ItemSelect)
                        {
                            if (objMR.MRType == MR.Type.Material)
                            {
                                bool isZero    = false;
                                bool Transfer  = true;
                                int  Stock     = 0;
                                int  zerocount = 0;
                                foreach (DataGridViewRow dr in gvItemList.Rows)
                                {
                                    MRMaterial objMRMat = new MRMaterial();
                                    objMRMat = (MRMaterial)dr.DataBoundItem;
                                    Stock    = objMRMaterialDL.Get_StockByStore(objStore.StoreID, objMRMat.Material.MaterialCode, objMRMat.IssuedQty);
                                    if (Stock == 0 && objMRMat.IssuedQty != 0)
                                    {
                                        MessageBox.Show(this, objMRMat.Material.MaterialCode + " Stock is lower than Issued Quantity,Please enter lower quantity", "Stock is not Enough", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        Transfer = false;
                                        break;
                                    }

                                    if (objMRMat.IssuedQty == 0)
                                    {
                                        isZero = true;
                                        zerocount++;
                                    }
                                }
                                if (Transfer)
                                {
                                    DialogResult drRes;
                                    if (zerocount >= gvItemList.Rows.Count)
                                    {
                                        MessageBox.Show(this, "Please enter a Issue Quantity", "Empty Field", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                    else
                                    {
                                        if (isZero)
                                        {
                                            drRes = MessageBox.Show(this, "One more items does not have a quantity, Do you want to continue\n\nClick Yes to continue", "Empty Quantities", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                                            if (drRes == DialogResult.Yes)
                                            {
                                                foreach (DataGridViewRow dr in gvItemList.Rows)
                                                {
                                                    MRMaterial objMRMat = new MRMaterial();
                                                    objMRMat = (MRMaterial)dr.DataBoundItem;
                                                    objMRMaterialDL.Issue(objMRMat, objStore.StoreID);
                                                }
                                                objMR.MRIssuedBy = CurrentUser.UserEmp.EmployeeID;
                                                objMR.MRStatus   = MR.Status.Issued;
                                                int x = objMRDL.Update_Issue(objMR);
                                                if (x > 0)
                                                {
                                                    bindItemList.DataSource = null;
                                                    Clear();

                                                    if (objStore != null)
                                                    {
                                                        bindMRList.DataSource = objMRDL.GetDataView(objStore.StoreID, MR.Status.Approved);
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            foreach (DataGridViewRow dr in gvItemList.Rows)
                                            {
                                                MRMaterial objMRMat = new MRMaterial();
                                                objMRMat = (MRMaterial)dr.DataBoundItem;
                                                objMRMaterialDL.Issue(objMRMat, objStore.StoreID);
                                            }
                                            objMR.MRIssuedBy = CurrentUser.UserEmp.EmployeeID;
                                            objMR.MRStatus   = MR.Status.Issued;
                                            int x = objMRDL.Update_Issue(objMR);
                                            if (x > 0)
                                            {
                                                bindItemList.DataSource = null;
                                                Clear();

                                                if (objStore != null)
                                                {
                                                    bindMRList.DataSource = objMRDL.GetDataView(objStore.StoreID, MR.Status.Approved);
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            if (objMR.MRType == MR.Type.BasicProduct)
                            {
                                IssueSemiFinished();
                            }

                            if (objMR.MRType == MR.Type.FinishProduct)
                            {
                                IssueFinishFinished();
                            }
                        }
                        else
                        {
                            MessageBox.Show(this, "Please Select a Material Requition", "Selection Empty", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show(this, "Stores list is empty", "Empty List", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }