Пример #1
0
        /// <summary>
        /// This method provides List of Returnable DCs available in Database.
        /// </summary>
        /// <param name="strWhere">Specifies condition for retrieving records.</param>
        /// <returns>Collection of Returnable DC Objects.</returns>
        public static ReturnableDCList GetList(string entryType, DateTime lvDate, bool flgShowAll)
        {
            ReturnableDCList objList = null;
            string           strSql  = "SELECT * " +
                                       " FROM ReturnableDC " +
                                       " WHERE ENTRYTYPE = @entryType ";

            if (!flgShowAll)
            {
                strSql += " AND ENTRYDATE = @entryDate ";
            }

            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("@entryType", entryType);

                    if (!flgShowAll)
                    {
                        objCmd.Parameters.AddWithValue("@entryDate", lvDate.ToString("dd-MMM-yy"));
                    }

                    if (Conn.State != ConnectionState.Open)
                    {
                        Conn.Open();
                    }

                    using (SqlDataReader oReader = objCmd.ExecuteReader())
                    {
                        if (oReader.HasRows)
                        {
                            objList = new ReturnableDCList();
                            while (oReader.Read())
                            {
                                objList.Add(FillDataRecord(oReader));
                            }
                        }
                        oReader.Close();
                        oReader.Dispose();
                    }
                }
            }
            return(objList);
        }
Пример #2
0
        private void FillList()
        {
            ReturnableDCList objList = new ReturnableDCList();

            objList = ReturnableDCManager.GetList(cboEntryType.Text, dtpDate.Value, flgShowAll);

            lvwDCList.Items.Clear();

            if (objList != null)
            {
                foreach (ReturnableDC objDC in objList)
                {
                    ListViewItem objLvwItem = new ListViewItem();
                    objLvwItem.Name = Convert.ToString(objDC.DBID);
                    objLvwItem.Text = Convert.ToString(objDC.EntryNo);
                    objLvwItem.SubItems.Add(objDC.EntryDate.ToShortDateString());
                    objLvwItem.SubItems.Add(objDC.PartyName);
                    objLvwItem.SubItems.Add(objDC.EntryType);
                    objLvwItem.SubItems.Add(objDC.DCNo);
                    objLvwItem.SubItems.Add(objDC.DCDate.ToShortDateString());
                    if (objDC.EntryType == "INWARD" & objDC.VOutDate != DateTime.MinValue)
                    {
                        objLvwItem.ForeColor = Color.Red;
                    }
                    //else
                    //    objLvwItem.ForeColor = Color.Blue;

                    if (objDC.EntryType == "OUTWARD" & objDC.VInDate != DateTime.MinValue)
                    {
                        objLvwItem.ForeColor = Color.Red;
                    }
                    //else
                    //    objLvwItem.ForeColor = Color.Blue;

                    lvwDCList.Items.Add(objLvwItem);
                }
            }
        }