//private int UpdateComboValue() //{ // //Boolean status = true; // int x = 0; // try // { // if (cmbProcessStatus.Text == "Closed") // { // return 1; // } // else if (cmbProcessStatus.Text == "Open") // { // return 0; // } // } // catch (Exception ex) // { // } // return x; //} private Boolean validateProcessStatus(productionplandetail ppd) { Boolean status = true; try { if (ppd.Remarks.Trim().Length == 0 || ppd.Remarks == null) { return(false); } if (ppd.ActualStartTime < ppd.ProductionPlanDate) { return(false); } if (ppd.ProcessStatus == 1) { //check for actual start and end dates if (ppd.ActualStartTime >= ppd.ActualEndTime) { return(false); } } } catch (Exception ex) { } return(status); }
private void grdProcessDetail_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } string columnName = grdProcessDetail.Columns[e.ColumnIndex].Name; if (columnName.Equals("Start") || columnName.Equals("End") || columnName.Equals("Remark")) { prevProdDetail = new productionplandetail(); prevProdDetail.DocumentID = "PRODUCTIONPLAN"; prevProdDetail.TemporaryNo = Convert.ToInt32(grdProcessDetail.Rows[e.RowIndex].Cells["cTempNo"].Value); prevProdDetail.TemporaryDate = Convert.ToDateTime(grdProcessDetail.Rows[e.RowIndex].Cells["cTempDate"].Value); prevProdDetail.SlNo = Convert.ToInt32(grdProcessDetail.Rows[e.RowIndex].Cells["SiNo"].Value); prevProdDetail.ProcessStatus = getProcessStatCode(grdProcessDetail.Rows[e.RowIndex].Cells["ProcessStatus"].Value.ToString()); prevProdDetail.Remarks = grdProcessDetail.Rows[e.RowIndex].Cells["cRemarks"].Value.ToString(); int prodstat = Convert.ToInt32(grdProcessDetail.Rows[e.RowIndex].Cells["ProdStat"].Value); if (columnName == "Start") { //if (!ProductionPlanHeaderDB.checkProductionProcessStatusAgainstRawmaterialIssue(prevProdDetail, prevProdDetail.TemporaryNo.ToString(), prevProdDetail.TemporaryDate)) //{ // MessageBox.Show("Raw Material Usage Not Finalized For this Production Plan.\nPlease update Process After finalizing RawMaterial Usage."); // return; //} Boolean isUpdateProdStat = false; if (prodstat == 1) // prodstat == 1 : Not started prodstat != 1 : started { isUpdateProdStat = true; } else { isUpdateProdStat = false; } if (prevProdDetail.ProcessStatus == 1) { MessageBox.Show("Production already Started."); return; } if (prevProdDetail.ProcessStatus == 99) { MessageBox.Show("Production already Closed."); return; } prevProdDetail.ActualStartTime = UpdateTable.getSQLDateTime(); string cmnt = Login.userLoggedInName + " : " + UpdateTable.getSQLDateTime().ToString("yyyy-MM-dd HH:mm:ss") + " : " + "Process started" + Environment.NewLine; prevProdDetail.Remarks = prevProdDetail.Remarks + cmnt; DialogResult dialog = MessageBox.Show("Are you sure to Start the process ?", "Yes", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { if (ProductionPlanHeaderDB.updateProductionProcessStatus(prevProdDetail, 1, isUpdateProdStat)) { MessageBox.Show("Production Started"); if (isUpdateProdStat) { prodstat = 2; } } else { MessageBox.Show("Failed to production start"); } } } if (columnName == "End") { if (prevProdDetail.ProcessStatus == 0) { MessageBox.Show("Production not started."); return; } if (prevProdDetail.ProcessStatus == 99) { MessageBox.Show("Production already closed."); return; } if (!ProductionPlanHeaderDB.checkProductionProcessStatusAgainstRawmaterialIssue(prevProdDetail, prevProdDetail.TemporaryNo.ToString(), prevProdDetail.TemporaryDate)) { MessageBox.Show("Raw Material Usage Not Finalized For this Production Plan.\nPlease update Process After finalizing RawMaterial Usage."); return; } string cmnt = Login.userLoggedInName + " : " + UpdateTable.getSQLDateTime().ToString("yyyy-MM-dd HH:mm:ss") + " : " + "Process closed" + Environment.NewLine; prevProdDetail.Remarks = prevProdDetail.Remarks + cmnt; prevProdDetail.ActualEndTime = UpdateTable.getSQLDateTime(); DialogResult dialog = MessageBox.Show("Are you sure to Close the process ?", "Yes", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { if (ProductionPlanHeaderDB.updateProductionProcessStatus(prevProdDetail, 2, false)) { MessageBox.Show("Production closed"); } else { MessageBox.Show("Failed to production close"); } } } if (columnName == "Remark") { showPopUpForDescription(); } productionplanheader pph = new productionplanheader(); pph.DocumentID = "PRODUCTIONPLAN"; pph.TemporaryNo = prevProdDetail.TemporaryNo; pph.TemporaryDate = prevProdDetail.TemporaryDate; pph.ProductionStatus = prodstat; showProcessDetails(pph); } } catch (Exception ex) { } }