/// <summary> /// This method provides List of VehInOut available in Database. /// </summary> /// <param name="strWhere">Specifies condition for retrieving records.</param> /// <returns>Collection of VehInOut Objects.</returns> public static VehInOutList GetList(string strWhere, DateTime vwDate, bool flgShowAll, int EntryType) { VehInOutList objList = null; string strSql = "SELECT * FROM VEHINOUTDETAIL"; if (!flgShowAll) { strSql += " WHERE ENTRYDATE = @entryDate "; if (strWhere != string.Empty) { strSql = strSql + " AND " + strWhere; } strSql += " AND TYPE = @mEntryType "; } else { if (strWhere != string.Empty) { strSql = strSql + " WHERE " + strWhere; strSql += " AND TYPE = @mEntryType "; } else { strSql += " WHERE TYPE = @mEntryType "; } } strSql += " ORDER BY ENTRYDATE DESC, ENTRYNO DESC"; using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString())) { using (SqlCommand objCmd = new SqlCommand()) { objCmd.Connection = Conn; objCmd.CommandType = CommandType.Text; objCmd.CommandText = strSql; objCmd.Parameters.AddWithValue("@mEntryType", EntryType); if (!flgShowAll) { objCmd.Parameters.AddWithValue("@entryDate", vwDate.ToString("dd-MMM-yy")); } if (Conn.State != ConnectionState.Open) { Conn.Open(); } using (SqlDataReader oReader = objCmd.ExecuteReader()) { if (oReader.HasRows) { objList = new VehInOutList(); while (oReader.Read()) { objList.Add(FillDataRecord(oReader)); } } oReader.Close(); oReader.Dispose(); } } } return(objList); }
private void FillList() { int intEntryType = 0; if (EntryType == "IN/OUT OTHER") { intEntryType = 1; } else if (EntryType == "COMPANY") { intEntryType = 4; } VehInOutList objList = new VehInOutList(); objList = VehInOutManager.GetList(dtpDate.Value, flgShowAll, intEntryType); lvwVehInOut.Items.Clear(); if (objList != null) { foreach (VehInOut objVehInOut in objList) { ListViewItem objLvwItem = new ListViewItem(); objLvwItem.Name = Convert.ToString(objVehInOut.Dbid); objLvwItem.Text = Convert.ToString(objVehInOut.EntryNo); if (objVehInOut.Type == 1) { objLvwItem.SubItems.Add("IN/OUT OTHER"); } else if (objVehInOut.Type == 4) { objLvwItem.SubItems.Add("COMPANY"); } objLvwItem.SubItems.Add(Convert.ToString(objVehInOut.VehNo)); if (objVehInOut.InOut == 1) { objLvwItem.SubItems.Add("IN"); } else if (objVehInOut.InOut == 2) { objLvwItem.SubItems.Add("OUT"); } objLvwItem.SubItems.Add(objVehInOut.DriverName); if (objVehInOut.InDate != DateTime.MinValue) { objLvwItem.SubItems.Add(objVehInOut.InDate.ToShortDateString()); } else { objLvwItem.SubItems.Add(""); } if (objVehInOut.InTime != DateTime.MinValue) { objLvwItem.SubItems.Add(objVehInOut.InTime.ToShortTimeString()); } else { objLvwItem.SubItems.Add(""); } if (objVehInOut.OutDate != DateTime.MinValue) { objLvwItem.SubItems.Add(objVehInOut.OutDate.ToShortDateString()); } else { objLvwItem.SubItems.Add(""); } if (objVehInOut.OutTime != DateTime.MinValue) { objLvwItem.SubItems.Add(objVehInOut.OutTime.ToShortTimeString()); } else { objLvwItem.SubItems.Add(""); } lvwVehInOut.Items.Add(objLvwItem); if (objVehInOut.InOut == 1) { objLvwItem.ForeColor = Color.Blue; } else if (objVehInOut.InOut == 2) { objLvwItem.ForeColor = Color.Red; } } } }