private void grdList_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } string columnName = grdList.Columns[e.ColumnIndex].Name; if (columnName.Equals("Det")) { string docid = grdList.Rows[e.RowIndex].Cells["gDocumentID"].Value.ToString(); int TempNo = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["gTemporaryNo"].Value); DateTime TmepDatechk = Convert.ToDateTime(grdList.Rows[e.RowIndex].Cells["gTemporaryDate"].Value); productionplanheader pph = new productionplanheader(); pph.DocumentID = docid; pph.TemporaryNo = TempNo; pph.TemporaryDate = TmepDatechk; pph.ProductionStatus = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["gProductionStatus"].Value); showProcessDetails(pph); } } catch (Exception ex) { } }
private void grdList_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } string columnName = grdList.Columns[e.ColumnIndex].Name; if (columnName.Equals("Finalize") || columnName.Equals("Edit")) { setButtonVisibility(columnName); //if (columnName.Equals("Finalize")) //{ // btnSave.Visible = false; // btnFinalize.Visible = true; //} //else //{ // btnSave.Visible = true; // btnFinalize.Visible = false; //} prevprodution = new productionplanheader(); prevprodution.TemporaryNo = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["gTemporaryNo"].Value.ToString()); prevprodution.TemporaryDate = DateTime.Parse(grdList.Rows[e.RowIndex].Cells["gTemporaryDate"].Value.ToString()); prevprodution.ProductionPlanNo = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["gProductionPlanNo"].Value.ToString()); prevprodution.ProductionPlanDate = DateTime.Parse(grdList.Rows[e.RowIndex].Cells["gProductionPlanDate"].Value.ToString()); prevprodution.InternalOrderNos = grdList.Rows[e.RowIndex].Cells["gInternalOrderNo"].Value.ToString(); prevprodution.InternalOrderDates = grdList.Rows[e.RowIndex].Cells["gInternalOrderDate"].Value.ToString(); prevprodution.StockItemID = grdList.Rows[e.RowIndex].Cells["gStockItemID"].Value.ToString(); prevprodution.StockItemName = grdList.Rows[e.RowIndex].Cells["gStockItemName"].Value.ToString(); prevprodution.ModelNo = grdList.Rows[e.RowIndex].Cells["gModelno"].Value.ToString(); prevprodution.ModelName = grdList.Rows[e.RowIndex].Cells["gModelName"].Value.ToString(); prevprodution.Quantity = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["gQuantity"].Value.ToString()); txtProductionPlanNo.Text = prevprodution.ProductionPlanNo.ToString(); dtProductionPlanDate.Value = prevprodution.ProductionPlanDate; txtModel.Text = prevprodution.ModelNo + "-" + prevprodution.ModelName; txtProductName.Text = prevprodution.StockItemName; if (!AddGridDetailRowForMU(Convert.ToInt32(txtProductionPlanNo.Text), dtProductionPlanDate.Value)) { MessageBox.Show("Failed to show Issue Dtails"); pnlBottomButtons.Visible = true; return; } grdList.Visible = false; pnlBottomButtons.Visible = false; pnlAddEdit.Visible = true; pnlAddEdit.BringToFront(); pnlAddEdit.Focus(); } } catch (Exception ex) { } }
private void grdList_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } string columnName = grdList.Columns[e.ColumnIndex].Name; if (columnName.Equals("Det")) { string docid = grdList.Rows[e.RowIndex].Cells["gDocumentID"].Value.ToString(); int TempNo = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["gTemporaryNo"].Value); DateTime TmepDatechk = Convert.ToDateTime(grdList.Rows[e.RowIndex].Cells["gTemporaryDate"].Value); productionplanheader pph = new productionplanheader(); pph.DocumentID = docid; pph.TemporaryNo = TempNo; pph.TemporaryDate = TmepDatechk; pph.ProductionPlanNo = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["gProductionPlanNo"].Value); pph.ProductionPlanDate = Convert.ToDateTime(grdList.Rows[e.RowIndex].Cells["gProductionPlanDate"].Value); pph.StockItemName = grdList.Rows[e.RowIndex].Cells["gStockItemName"].Value.ToString(); pph.Quantity = Convert.ToDouble(grdList.Rows[e.RowIndex].Cells["gQuantity"].Value); pph.PlannedStartTime = Convert.ToDateTime(grdList.Rows[e.RowIndex].Cells["gPlannedStartTime"].Value); pph.PlannedEndTime = Convert.ToDateTime(grdList.Rows[e.RowIndex].Cells["gPlannedEndTime"].Value); pph.ActualStartTime = Convert.ToDateTime(grdList.Rows[e.RowIndex].Cells["gActualStartTime"].Value); pph.ActualEndTime = Convert.ToDateTime(grdList.Rows[e.RowIndex].Cells["gActualEndTime"].Value); pph.ProductionStatus = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["gProductionStatus"].Value); txtProductionPlanNo.Text = pph.ProductionPlanNo.ToString(); dtProductionPlanDate.Value = pph.ProductionPlanDate; //txtModel.Text = pph.ModelName; txtProductName.Text = pph.StockItemName; dtPlannedStartTime.Value = pph.PlannedStartTime; dtPlanedEndTime.Value = pph.PlannedEndTime; txtQuantity.Text = pph.Quantity.ToString(); fillProductionStatusCumbo(pph.ProductionStatus); //Get Actual Start And End Time DateTime[] dtArr = ProductionPlanHeaderDB. getActualStartAndEndTimeForAPlan(pph.ProductionPlanNo, pph.ProductionPlanDate); dtActualStartTime.Value = dtArr[0]; dtActualEndTime.Value = dtArr[1]; cmbProductionStatus.Enabled = true; pnlList.Visible = true; pnlAddEdit.Visible = true; btnCancel.Visible = true; btnSave.Visible = true; pnlAddEdit.BringToFront(); } } catch (Exception ex) { } }
//called when new,cancel buttons are clicked. //called at the end of event processing for forward, approve,reverse and save public void clearData() { try { //grdProductionPlanDetail.Rows.Clear(); dgvComments.Rows.Clear(); dgvpt.Rows.Clear(); prevprodution = new productionplanheader(); removeControlsFrompnllvPanel(); } catch (Exception ex) { } }
//----- private void grdList_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { string docid = grdList.Rows[e.RowIndex].Cells["gDocumentID"].Value.ToString(); int TempNo = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["gTemporaryNo"].Value); DateTime TmepDatechk = Convert.ToDateTime(grdList.Rows[e.RowIndex].Cells["gTemporaryDate"].Value); productionplanheader pph = new productionplanheader(); pph.DocumentID = docid; pph.TemporaryNo = TempNo; pph.TemporaryDate = TmepDatechk; showProcessDetails(pph); } catch (Exception ex) { } }
//called when new,cancel buttons are clicked. //called at the end of event processing for forward, approve,reverse and save public void clearData() { try { cmbProductionStatus.Enabled = false; pnlAddEdit.Visible = false; cmbProductionStatus.Text = ""; cmbProductionStatus.Items.Clear(); txtProductionPlanNo.Text = ""; dtProductionPlanDate.Value = DateTime.Parse("01-01-1900"); txtProductName.Text = ""; txtModel.Text = ""; txtQuantity.Text = ""; prevprodution = new productionplanheader(); } catch (Exception ex) { } }
//called when new,cancel buttons are clicked. //called at the end of event processing for forward, approve,reverse and save public void clearData() { try { //grdProductionPlanDetail.Rows.Clear(); dgvComments.Rows.Clear(); dgvpt.Rows.Clear(); grdSIDetail.Rows.Clear(); prevprodution = new productionplanheader(); clearTabPageControls(); pnlCmtr.Visible = false; pnlForwarder.Visible = false; pnllv.Visible = false; txtProductionPlanNo.Text = ""; dtProductionPlanDate.Value = DateTime.Parse("01-01-1900"); txtProductName.Text = ""; txtModel.Text = ""; removeControlsFrompnllvPanel(); } catch (Exception ex) { } }
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) { } }
private void showProcessDetails(productionplanheader pph) { try { List <productionplandetail> processdetial = ProductionPlanHeaderDB.getProductionPlanDetail(pph); ERPUserDB erpuser = new ERPUserDB(); grdProcessDetail.Visible = true; btnClose.Visible = true; //grdProcessDetail.Refresh(); grdProcessDetail.Rows.Clear(); int i = 0; try { foreach (productionplandetail ppd in processdetial) { AddProductionPlanDetailRow(); grdProcessDetail.Rows[i].Cells["ProdStat"].Value = pph.ProductionStatus; grdProcessDetail.Rows[i].Cells["cTempNo"].Value = pph.TemporaryNo; grdProcessDetail.Rows[i].Cells["cTempDate"].Value = pph.TemporaryDate; grdProcessDetail.Rows[i].Cells["ProcessID"].Value = ppd.ProcessID; grdProcessDetail.Rows[i].Cells["SiNo"].Value = ppd.SlNo; grdProcessDetail.Rows[i].Cells["ProcessDescription"].Value = ppd.ProcessDescription; grdProcessDetail.Rows[i].Cells["TeamMembers"].Value = ppd.TeamMembers; grdProcessDetail.Rows[i].Cells["StartTime"].Value = ppd.StartTime; grdProcessDetail.Rows[i].Cells["EndTime"].Value = ppd.EndTime; grdProcessDetail.Rows[i].Cells["cActualaStartTime"].Value = ppd.ActualStartTime; grdProcessDetail.Rows[i].Cells["cActualEndTime"].Value = ppd.ActualEndTime; grdProcessDetail.Rows[i].Cells["TeamMembers"].Value = erpuser.getUserNames(ppd.TeamMembers); grdProcessDetail.Rows[i].Cells["ProcessStatus"].Value = getProcessStatString(ppd.ProcessStatus); if (ppd.ProcessStatus == 1) { grdProcessDetail.Rows[i].DefaultCellStyle.BackColor = Color.LightGreen; } else if (ppd.ProcessStatus == 99) { grdProcessDetail.Rows[i].DefaultCellStyle.BackColor = Color.DarkTurquoise; } else { grdProcessDetail.Rows[i].DefaultCellStyle.BackColor = Color.CadetBlue; } grdProcessDetail.Rows[i].Cells["cRemarks"].Value = ppd.Remarks; i++; } int n = getuserPrivilegeStatus(); if (n == 1) { grdProcessDetail.Columns["Start"].Visible = false; grdProcessDetail.Columns["End"].Visible = false; } else { grdProcessDetail.Columns["Start"].Visible = true; grdProcessDetail.Columns["End"].Visible = true; } } catch (Exception ex) { } } catch (Exception ex) { } }
private void btnSave_Click(object sender, EventArgs e) { Boolean status = true; try { ProductionPlanHeaderDB phDB = new ProductionPlanHeaderDB(); System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btnSave.Text; if (cmbProductionStatus.SelectedIndex == -1) { MessageBox.Show("Select Production Status"); return; } if (btnText.Equals("Save")) { int stat = Convert.ToInt32(((Structures.ComboBoxItem)cmbProductionStatus.SelectedItem).HiddenValue); if ((dtActualEndTime.Value <= dtActualStartTime.Value) && stat != 3 && stat != 4 && stat != 5) { MessageBox.Show("Actual End Time should be more than the actual start time."); return; } int planNo = Convert.ToInt32(txtProductionPlanNo.Text); string loc = "FACTORYSTORE"; DateTime planDate = dtProductionPlanDate.Value; productionplanheader pph = new productionplanheader(); if (!ProductionPlanHeaderDB.checkproductionClosedStatus(planNo, planDate) && stat == 99) { MessageBox.Show("CLose all production process for this production plan."); MessageBox.Show("Failed to update Status"); return; } DialogResult dialog = MessageBox.Show("Are you sure to Finalize the production?", "Yes", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { ///return; pph = phDB.getProductionPlanHeaderDetail(planNo, planDate); //Storing Actual StartTIme And Actual End time pph.ActualStartTime = dtActualStartTime.Value; pph.ActualEndTime = dtActualEndTime.Value; if (phDB.updateProductionStatus(stat, pph, loc)) { MessageBox.Show("Status updated"); if (stat == 99) { MessageBox.Show("Stock Added TO Factory Store."); } pnlAddEdit.Visible = false; ListFilteredProductionPlanHeader(); } else { MessageBox.Show("Failed to update Status"); pnlAddEdit.Visible = false; status = false; } } else { status = false; } } else { status = false; } } catch (Exception ex) { MessageBox.Show("btnSave_Click_1() : Error"); status = false; } if (status) { setButtonVisibility("btnEditPanel"); //activites are same for cancel, forward,approve, reverse and save } }