public Boolean insertDocumentReceiver(documentreceiver doc) { Boolean status = true; string utString = ""; try { DateTime cdt = DateTime.Now; string updateSQL = "insert into DocumentReceiver (DocumentID,EmployeeID,OfficeID,Status,CreateTime,CreateUser)" + "values (" + "'" + doc.DocumentID + "'," + "'" + doc.EmployeeID + "'," + "'" + doc.OfficeID + "'," + doc.Status + "," + "GETDATE()" + "," + "'" + Login.userLoggedIn + "'" + ")"; utString = utString + updateSQL + Main.QueryDelimiter; utString = utString + ActivityLogDB.PrepareActivityLogQquerString("insert", "DocumentReceiver", "", updateSQL) + Main.QueryDelimiter; if (!UpdateTable.UT(utString)) { status = false; } } catch (Exception ex) { MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); status = false; } return(status); }
public Boolean validateDocument(documentreceiver doc) { Boolean status = true; try { if (doc.DocumentID.Trim().Length == 0 || doc.DocumentID == null) { return(false); } if (doc.EmployeeID.Trim().Length == 0 || doc.EmployeeID == null) { return(false); } } catch (Exception ex) { MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); return(false); } return(status); }
public List <documentreceiver> getDocumentReceiver() { documentreceiver drrec; List <documentreceiver> DocumentReceivers = new List <documentreceiver>(); try { SqlConnection conn = new SqlConnection(Login.connString); string query = "select a.DocumentID, b.DocumentName,a.EmployeeID,c.Name, a.officeid," + "d.Name, a.status,a.RowId from DocumentReceiver a, Document b, " + "Employee c, Office d where a.DocumentID=b.DocumentID and " + "a.EmployeeID=c.EmployeeID and a.OfficeID=d.OfficeID " + "order by a.DocumentID,c.Name"; SqlCommand cmd = new SqlCommand(query, conn); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { drrec = new documentreceiver(); drrec.DocumentID = reader.GetString(0); drrec.DocumentName = reader.GetString(1); drrec.EmployeeID = reader.GetString(2); drrec.EmployeeName = reader.GetString(3); drrec.OfficeID = reader.GetString(4); drrec.OfficeName = reader.GetString(5); drrec.Status = reader.GetInt32(6); drrec.RowID = reader.GetInt32(7); DocumentReceivers.Add(drrec); } conn.Close(); } catch (Exception ex) { MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); } return(DocumentReceivers); }
public static void fillCatalogValueComboNew2(System.Windows.Forms.ComboBox cmb, System.Windows.Forms.ComboBox cmb2, System.Windows.Forms.ComboBox cmb3, System.Windows.Forms.Label Label) { cmb.Items.Clear(); cmb2.Items.Clear(); cmb3.Items.Clear(); try { CatalogueValueDB dbrecord = new CatalogueValueDB(); List <cataloguevalue> CatalogueValues = dbrecord.getCatalogueValues().Where(W => W.catalogueID == "POType").ToList(); List <documentreceiver> ListL2 = new List <documentreceiver>(); List <documentreceiver> ListL3 = new List <documentreceiver>(); List <documentreceiver> ListL = Main.DocumentReceivers.Where(W => W.Status == 1).ToList(); OfficeDB obj2 = new OfficeDB(); DocumentDB obj3 = new DocumentDB(); var Ofices = obj2.getOffices().Where(W => W.status == 1).ToList(); string DocName = ""; foreach (var itm in ListL) { documentreceiver obj = new documentreceiver(); DocName = itm.DocumentID; DocName = DocName.Replace("POSERVICEINWARD", "Service PO"); DocName = DocName.Replace("PAFSERVICEINWARD", "ServicePAF"); DocName = DocName.Replace("POPRODUCTINWARD", "Product PO"); DocName = DocName.Replace("PAFPRODUCTINWARD", "ProductPAF"); obj.DocumentName = DocName; obj.OfficeID = itm.OfficeID; obj.OfficeName = itm.OfficeName; obj.DocumentID = itm.DocumentID; ListL2.Add(obj); } string[] Str = new string[4]; ////int i = 0; foreach (var itm in CatalogueValues) { documentreceiver obj = new documentreceiver(); DocName = itm.description; DocName = DocName.Replace("Service PO", "POSERVICEINWARD"); DocName = DocName.Replace("ServicePAF", "PAFSERVICEINWARD"); DocName = DocName.Replace("Product PO", "POPRODUCTINWARD"); DocName = DocName.Replace("ProductPAF", "PAFPRODUCTINWARD"); obj.DocumentID = DocName; obj.DocumentName = itm.description; ListL3.Add(obj); } var abcsd = from Ca in CatalogueValues join Ll in ListL2 on Ca.description equals Ll.DocumentName select new { DocumentName = Ca.description, DocumentID = Ll.DocumentID, Ofice = Ll.OfficeID, OficeName = Ll.OfficeName }; var Off = from Ca in Ofices join Ll in abcsd on Ca.OfficeID equals Ll.Ofice select Ca; // cmb.Items.AddRange(ListL.ToArray()); foreach (var itm in abcsd.GroupBy(x => x.DocumentName).Select(y => y.FirstOrDefault()).ToList()) { Structures.ComboBoxItem cbitem = new Structures.ComboBoxItem(itm.DocumentName, itm.DocumentID); cmb.Items.Add(cbitem); } var Abcd2 = abcsd.GroupBy(x => x.Ofice).Select(y => y.FirstOrDefault()).ToList(); foreach (var itm in Abcd2) { Structures.ComboBoxItem cbitem2 = new Structures.ComboBoxItem(itm.OficeName, itm.Ofice); cmb2.Items.Add(cbitem2); } foreach (var itm in Ofices.GroupBy(G => G.RegionID)) { Structures.ComboBoxItem cbitem = new Structures.ComboBoxItem(itm.Key, itm.Select(s => s.RegionName).FirstOrDefault()); cmb3.Items.Add(cbitem); } if (ListL.Count <= 0) { Label.Text = "1"; var Documents = obj3.getDocuments().Where(W => W.DocumentStatus == 1).ToList(); var results = from x in Documents join Ll in ListL3 on x.DocumentID equals Ll.DocumentID select new { DocumntId = x.DocumentID, documntname = Ll.DocumentName }; foreach (var itm in results) { Structures.ComboBoxItem cbitem = new Structures.ComboBoxItem(itm.documntname, itm.DocumntId); cmb.Items.Add(cbitem); } foreach (var itm in Ofices) { Structures.ComboBoxItem cbitem = new Structures.ComboBoxItem(itm.name, itm.OfficeID); cmb2.Items.Add(cbitem); } // offli = Ofices.ToList(); } } catch (Exception ex) { MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); } }