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