private void AddSMRNServListRow(smrnservicedlist tempServ) { List <smrndetail> SMRNDetail = SMRNServicedListDB.getSMRNDetailForServiceList(tempServ, 2); grdSMRNServList.Rows.Clear(); grdSMRNServList.Columns["Check"].Visible = true; int i = 0; foreach (smrndetail smrnd in SMRNDetail) { if (!AddSMRNDetailRow()) { MessageBox.Show("Error found in Adding rows to SMRNGrdiDetail."); } else { grdSMRNServList.Rows[i].Cells["Item"].Value = smrnd.StockItemID + "-" + smrnd.StockItemName; grdSMRNServList.Rows[i].Cells["SerialNo"].Value = smrnd.SerialNo; grdSMRNServList.Rows[i].Cells["ItemDetails"].Value = smrnd.ItemDetails; grdSMRNServList.Rows[i].Cells["WarrantyStatus"].Value = showStatus(smrnd.WarrantyStatus); grdSMRNServList.Rows[i].Cells["ProductServiceStatus"].Value = smrnd.ProductServiceStatus; grdSMRNServList.Rows[i].Cells["gSMRNHeaderNo"].Value = smrnd.InspectionStatus; // for SMRNHeaderNo grdSMRNServList.Rows[i].Cells["gSMRNHeaderDate"].Value = smrnd.TemporaryDate; // for SMRN HEader date grdSMRNServList.Rows[i].Cells["gTemporaryNo"].Value = smrnd.TemporaryNo; grdSMRNServList.Rows[i].Cells["gTemporarydate"].Value = smrnd.TemporaryDate; grdSMRNServList.Rows[i].Cells["JobId"].Value = smrnd.JobIDNo; } i++; } }
public void clearData() { try { //clear all grid views dgvComments.Rows.Clear(); dgvpt.Rows.Clear(); grdSMRNServList.Rows.Clear(); //----------clear temperory panels clearTabPageControls(); pnlCmtr.Visible = false; pnlForwarder.Visible = false; //dtSMRNHeaderDate.Value = DateTime.Parse("01-01-1900"); dtListDate.Value = DateTime.Parse("01-01-1900"); txtListNo.Text = ""; txtCustomer.Text = ""; txtCustPONo.Text = ""; txtTrackingNo.Text = ""; btnSelectSMRNHeaderNo.Enabled = true; grdSMRNServList.ReadOnly = false; //txtSMRNHeaderNo.Text = ""; prevservlist = new smrnservicedlist(); removeControlsFromPnlLvPanel(); } catch (Exception ex) { } }
private void lvOK_Click(object sender, EventArgs e) { try { if (!checkLVItemChecked("SMRN")) { return; } //btnSelectSMRNHeaderNo.Enabled = true; //pnllv.Visible = false; foreach (ListViewItem itemRow in lv.Items) { if (itemRow.Checked) { txtTrackingNo.Text = itemRow.SubItems[1].Text; dtTrackingDate.Value = Convert.ToDateTime(itemRow.SubItems[2].Text); txtCustPONo.Text = itemRow.SubItems[5].Text; txtCustomer.Text = itemRow.SubItems[3].Text + "-" + itemRow.SubItems[4].Text; dtCustPODate.Value = Convert.ToDateTime(itemRow.SubItems[6].Text); //tempNo = itemRow.SubItems[7].Text; //tempDate = Convert.ToDateTime(itemRow.SubItems[8].Text); smrnservicedlist tempServ = new smrnservicedlist(); tempServ.TrackingNo = Convert.ToInt32(itemRow.SubItems[1].Text); tempServ.TrackingDate = Convert.ToDateTime(itemRow.SubItems[2].Text); AddSMRNServListRow(tempServ); } } frmPopup.Close(); frmPopup.Dispose(); } catch (Exception ex) { } }
private void btnDelete_Click(object sender, EventArgs e) { bool status = true; try { DialogResult dialog = MessageBox.Show("Are you sure to delete the document ?", "Yes", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { SMRNServicedListDB ServListDB = new SMRNServicedListDB(); smrnservicedlist smrnserv; List <smrnservicedlist> SMRNServList = new List <smrnservicedlist>(); for (int i = 0; i < grdSMRNServList.Rows.Count; i++) { smrnserv = new smrnservicedlist(); smrnserv.SMRNHeaderNo = Convert.ToInt32(grdSMRNServList.Rows[i].Cells["gSMRNHeaderNo"].Value.ToString().Trim()); smrnserv.SMRNHeaderDate = Convert.ToDateTime(grdSMRNServList.Rows[i].Cells["gSMRNHeaderDate"].Value.ToString().Trim()); smrnserv.JobIDNo = Convert.ToInt32(grdSMRNServList.Rows[i].Cells["JobId"].Value.ToString().Trim()); smrnserv.ListNo = Convert.ToInt32(grdSMRNServList.Rows[i].Cells["gTemporaryNo"].Value.ToString().Trim()); /// For storing TemporaryNo of SMRNDetail smrnserv.ListDate = Convert.ToDateTime(grdSMRNServList.Rows[i].Cells["gTemporaryDate"].Value.ToString().Trim()); ////for storing temporaryDate of SMRNdetail SMRNServList.Add(smrnserv); } if (ServListDB.updateSMRNServicedList(prevservlist, SMRNServList, 2)) { MessageBox.Show("SMRNService List Deleted"); closeAllPanels(); listOption = 1; ListFilteredSMRNServiceList(listOption); //pnlBottomActions.Visible = true; } else { MessageBox.Show("Failed to Delete"); status = false; } } else { return; } } catch (Exception ex) { } if (!status) { MessageBox.Show("Failed to Delete"); status = false; } if (status) { setButtonVisibility("btnEditPanel"); //activites are same for cancel, forward,approve, reverse and save } }
private Boolean AddSMRNServListRowForFinalize(smrnservicedlist prevservlist) { Boolean status = true; try { List <smrndetail> SMRNDetail = SMRNServicedListDB.getSMRNDetailForServiceList(prevservlist, 1); grdSMRNServList.Rows.Clear(); int i = 0; foreach (smrndetail smrnd in SMRNDetail) { if (!AddSMRNDetailRow()) { status = false; MessageBox.Show("Error found in Adding rows to SMRNGrdiDetail."); } else { grdSMRNServList.Rows[i].Cells["Item"].Value = smrnd.StockItemID + "-" + smrnd.StockItemName; grdSMRNServList.Rows[i].Cells["SerialNo"].Value = smrnd.SerialNo; grdSMRNServList.Rows[i].Cells["ItemDetails"].Value = smrnd.ItemDetails; grdSMRNServList.Rows[i].Cells["WarrantyStatus"].Value = showStatus(smrnd.WarrantyStatus); grdSMRNServList.Rows[i].Cells["ProductServiceStatus"].Value = smrnd.ProductServiceStatus; grdSMRNServList.Rows[i].Cells["gSMRNHeaderNo"].Value = smrnd.InspectionStatus; // for SMRNHeaderNo grdSMRNServList.Rows[i].Cells["gSMRNHeaderDate"].Value = smrnd.TemporaryDate; // for SMRN HEader date grdSMRNServList.Rows[i].Cells["gTemporaryNo"].Value = smrnd.TemporaryNo; grdSMRNServList.Rows[i].Cells["gTemporarydate"].Value = smrnd.TemporaryDate; grdSMRNServList.Rows[i].Cells["JobId"].Value = smrnd.JobIDNo; } i++; } } catch (Exception ex) { status = false; } return(status); }
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("View") || columnName.Equals("Print")) { if (columnName.Equals("Finalize")) { grdSMRNServList.Columns["Check"].Visible = false; grdSMRNServList.ReadOnly = true; btnSelectSMRNHeaderNo.Enabled = false; } clearData(); setButtonVisibility(columnName); docID = grdList.Rows[e.RowIndex].Cells[0].Value.ToString(); QIHeaderDB qidb = new QIHeaderDB(); int rowID = e.RowIndex; btnSave.Text = "Update"; DataGridViewRow row = grdList.Rows[rowID]; prevservlist = new smrnservicedlist(); prevservlist.DocumentID = grdList.Rows[e.RowIndex].Cells["gDocumentID"].Value.ToString(); prevservlist.ListNo = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["ListNo"].Value.ToString()); prevservlist.ListDate = DateTime.Parse(grdList.Rows[e.RowIndex].Cells["ListDate"].Value.ToString()); prevservlist.TrackingNo = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["gTrackingNo"].Value.ToString()); prevservlist.TrackingDate = DateTime.Parse(grdList.Rows[e.RowIndex].Cells["gtrackingDate"].Value.ToString()); prevservlist.CustomerPONo = grdList.Rows[e.RowIndex].Cells["gCustomerPONo"].Value.ToString(); prevservlist.CustomerPODate = DateTime.Parse(grdList.Rows[e.RowIndex].Cells["gCustomerPODate"].Value.ToString()); prevservlist.CustomerID = grdList.Rows[e.RowIndex].Cells["Customer"].Value.ToString(); if (columnName.Equals("Print")) { pnlAddEdit.Visible = false; pnlList.Visible = true; grdList.Visible = true; btnNew.Visible = true; btnExit.Visible = true; PrintSMRNServicedList printServ = new PrintSMRNServicedList(); List <smrndetail> SMRNDetail = SMRNServicedListDB.getSMRNDetailForServiceList(prevservlist, 1); printServ.PrintServicedList(SMRNDetail, prevservlist); btnNew.Visible = true; btnExit.Visible = true; return; } txtListNo.Text = prevservlist.ListNo.ToString(); txtTrackingNo.Text = prevservlist.TrackingNo.ToString(); txtCustomer.Text = prevservlist.CustomerID; txtCustPONo.Text = prevservlist.CustomerPONo; dtCustPODate.Value = prevservlist.CustomerPODate; dtListDate.Value = prevservlist.ListDate; if (!AddSMRNServListRowForFinalize(prevservlist)) { MessageBox.Show("failed to add rows in grdSMRNServList"); } btnSave.Text = "Update"; pnlList.Visible = false; pnlAddEdit.Visible = true; btnSave.Text = "Update"; pnlList.Visible = false; pnlAddEdit.Visible = true; } } catch (Exception ex) { MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); } }
private void btnSave_Click(object sender, EventArgs e) { Boolean status = true; try { List <smrnservicedlist> SMRNServList; SMRNServicedListDB ServListDB = new SMRNServicedListDB(); smrnservicedlist ServList = new smrnservicedlist(); System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btnSave.Text; try { ServList.DocumentID = docID; smrnservicedlist smrnserv; SMRNServList = new List <smrnservicedlist>(); for (int i = 0; i < grdSMRNServList.Rows.Count; i++) { try { DataGridViewCheckBoxCell cell = grdSMRNServList.Rows[i].Cells["check"] as DataGridViewCheckBoxCell; if (cell.Value != null) { if (Convert.ToBoolean(cell.Value) == true) { smrnserv = new smrnservicedlist(); smrnserv.SMRNHeaderNo = Convert.ToInt32(grdSMRNServList.Rows[i].Cells["gSMRNHeaderNo"].Value.ToString().Trim()); smrnserv.SMRNHeaderDate = Convert.ToDateTime(grdSMRNServList.Rows[i].Cells["gSMRNHeaderDate"].Value.ToString().Trim()); smrnserv.JobIDNo = Convert.ToInt32(grdSMRNServList.Rows[i].Cells["JobId"].Value.ToString().Trim()); smrnserv.ListNo = Convert.ToInt32(grdSMRNServList.Rows[i].Cells["gTemporaryNo"].Value.ToString().Trim()); /// For storing TemporaryNo of SMRNDetail smrnserv.ListDate = Convert.ToDateTime(grdSMRNServList.Rows[i].Cells["gTemporaryDate"].Value.ToString().Trim()); ////for storing temporaryDate of SMRNdetail SMRNServList.Add(smrnserv); } } } catch (Exception ex) { MessageBox.Show("createAndUpdateSMRNDetails() : Error creating SMRN Details"); status = false; return; } } ServList.Status = 1; } catch (Exception ex) { MessageBox.Show("Validation failed"); return; } if (btnText.Equals("Save")) { ServList.ListNo = DocumentNumberDB.getNewNumber(docID, 1); ServList.DocumentStatus = 1; ServList.ListDate = UpdateTable.getSQLDateTime(); } else { ServList.ListNo = Convert.ToInt32(txtListNo.Text); ServList.DocumentStatus = prevservlist.DocumentStatus; ServList.ListDate = prevservlist.ListDate; } if (btnText.Equals("Save")) { if (ServListDB.updateSMRNServicedList(ServList, SMRNServList, 1)) { MessageBox.Show("SMRNService List Details Added"); closeAllPanels(); listOption = 1; ListFilteredSMRNServiceList(listOption); } else { status = false; } if (!status) { MessageBox.Show("Failed to Insert SMRNServiceList"); status = false; } } else { MessageBox.Show("SMRNServiceList Validation failed"); status = false; } } catch (Exception ex) { MessageBox.Show("SMRNServiceList Validation failed"); status = false; } if (status) { setButtonVisibility("btnEditPanel"); //activites are same for cancel, forward,approve, reverse and save } }
public string PrintServicedList(List <smrndetail> smrnList, smrnservicedlist list) { string pathStr = ""; string HeaderString = "List No:" + list.ListNo + ";List Date:" + list.ListDate + ";Customer:" + list.CustomerID + ";CustomerPO No:" + list.CustomerPONo + ";CustomerPO Date:" + list.CustomerPODate; string ColHeader = ColHeader = "SI No.;Items;itemDetails;SerielNo;ServiceStatus"; string fileName = list.TrackingNo + "-" + list.ListNo; string Title = "List Of Serviced Items"; string subDir = list.ListNo + "-" + list.ListDate.ToString("yyyyMMddhhmmss"); string dicDir = Main.documentDirectory + "\\" + list.DocumentID; int n = 1; string ColDetailString = ""; var count = smrnList.Count(); foreach (smrndetail smrnd in smrnList) { if (n == count) { ColDetailString = ColDetailString + n + "+" + smrnd.StockItemID + "+" + smrnd.ItemDetails + "+" + smrnd.SerialNo + "+" + smrnd.ProductServiceStatus; } else { ColDetailString = ColDetailString + n + "+" + smrnd.StockItemID + "+" + smrnd.ItemDetails + "+" + smrnd.SerialNo + "+" + smrnd.ProductServiceStatus + ";"; } n++; } try { string dir = dicDir + "\\" + subDir; if (!System.IO.Directory.Exists(dir)) { System.IO.Directory.CreateDirectory(dir); } string Fname = dir + "\\" + fileName; FileStream fs = new FileStream(Fname + ".pdf", FileMode.Create, FileAccess.Write); Rectangle rec = new Rectangle(PageSize.A4); iTextSharp.text.Document doc = new iTextSharp.text.Document(rec); PdfWriter writer = PdfWriter.GetInstance(doc, fs); MyEvent evnt = new MyEvent(); writer.PageEvent = evnt; doc.Open(); Font font1 = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK); Font font2 = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK); Font font3 = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.ITALIC, BaseColor.BLACK); Paragraph paragraph = new Paragraph(new Phrase(Title, font2)); paragraph.Alignment = Element.ALIGN_CENTER; string[] HeaderStr = HeaderString.Split(';'); Paragraph pheader = new Paragraph(); foreach (string str in HeaderStr) { Phrase ph = new Phrase(); ph.Add(new Chunk(str.Substring(0, str.IndexOf(':') + 1), font2)); ph.Add(new Chunk(str.Substring(str.IndexOf(':') + 1) + "\n", font1)); pheader.Add(ph); } string[] ColHeaderStr = ColHeader.Split(';'); PdfPTable table1 = new PdfPTable(5); table1.DefaultCell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; table1.WidthPercentage = 100; float[] width = new float[] { 3f, 3f, 3f, 3f, 3f }; table1.SetWidths(width); table1.SpacingBefore = 20f; for (int i = 0; i < ColHeaderStr.Length; i++) { PdfPCell hcell = new PdfPCell(new Phrase(ColHeaderStr[i].Trim(), font2)); hcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; table1.AddCell(hcell); string str = ColHeaderStr[i]; } PdfPCell foot = new PdfPCell(new Phrase("")); foot.Colspan = 5; foot.BorderWidthTop = 0; foot.MinimumHeight = 0.5f; table1.AddCell(foot); table1.HeaderRows = 2; table1.FooterRows = 1; table1.SkipFirstHeader = false; table1.SkipLastFooter = true; string[] DetailStr = ColDetailString.Split(';'); for (int i = 0; i < DetailStr.Length; i++) { string[] str = DetailStr[i].Split('+'); for (int j = 0; j < str.Length; j++) { PdfPCell pcell; string s = str[j]; pcell = new PdfPCell(new Phrase(str[j], font1)); pcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; table1.AddCell(pcell); } } doc.Add(paragraph); doc.Add(pheader); doc.Add(table1); doc.Close(); pathStr = dir + "\\" + fileName + ".pdf"; documentStorage ds = new documentStorage(); DocumentStorageDB dsdb = new DocumentStorageDB(); ds.DocumentID = list.DocumentID; ds.Directory = subDir; ds.FileName = fileName + ".pdf"; ds.Description = "SMRNServiceList" + list.ListNo; if (dsdb.validateDocumentDetails(ds)) { if (dsdb.iskDocumentDuplication(ds)) { if (dsdb.UpdateDocumentDetails(ds)) { MessageBox.Show("DocumetnStorage Updated"); } else { MessageBox.Show("failed to update documentStorage"); } } else { if (dsdb.InsertDocumentDetails(ds)) { MessageBox.Show("DocumetnStorage Updated"); } else { MessageBox.Show("failed to update documentStorage"); } } } } catch (Exception ie) { } return(pathStr); }