public static List <Phone> GetDealsList(int?id, string MyBrands, ProductType?myType, string myName, string MyOSTypes, float?myMinPrice, float?myMaxPrice, bool mySale = true)
        {
            List <Phone>  phoneList = new List <Phone>();
            Phone         PH        = null;
            SqlConnection con       = new SqlConnection(connStr);
            SqlCommand    cmd       = new SqlCommand("GetDealsList", con);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter  param;
            SqlDataReader dr;

            try
            {
                if (id != null)
                {
                    param = new SqlParameter("ID", id);
                    cmd.Parameters.Add(param);
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("ID", DBNull.Value));
                }

                if (myType != null)
                {
                    param = new SqlParameter("PrType", myType);
                    cmd.Parameters.Add(param);
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("PrType", DBNull.Value));
                }

                if (myName != null)
                {
                    param = new SqlParameter("Name", myName);
                    cmd.Parameters.Add(param);
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("Name", DBNull.Value));
                }

                if (MyOSTypes != null)
                {
                    param = new SqlParameter("OSs", MyOSTypes);
                    cmd.Parameters.Add(param);
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("OSs", DBNull.Value));
                }

                if (MyBrands != null)
                {
                    param = new SqlParameter("Brands", MyBrands);
                    cmd.Parameters.Add(param);
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("Brands", DBNull.Value));
                }

                if (myMinPrice != null)
                {
                    param = new SqlParameter("MinPrice", myMinPrice);
                    cmd.Parameters.Add(param);
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("MinPrice", DBNull.Value));
                }

                if (myMaxPrice != null)
                {
                    param = new SqlParameter("MaxPrice", myMaxPrice);
                    cmd.Parameters.Add(param);
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("MaxPrice", DBNull.Value));
                }


                param = new SqlParameter("Sale", mySale);
                cmd.Parameters.Add(param);


                con.Open();
                dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    PH           = new Phone();
                    PH.Id        = Convert.ToInt32(dr["ID"]);
                    PH.Name      = dr["Name"].ToString();
                    PH.Brand     = (Brands)Convert.ToByte(dr["Brand"]);
                    PH.Available = Convert.ToBoolean(dr["Available"]);
                    if (dr["PublishDate"] == DBNull.Value)
                    {
                        PH.PublishDate = null;
                    }
                    else
                    {
                        PH.PublishDate = Convert.ToDateTime(dr["PublishDate"]);
                    }

                    if (dr["ImgUrl"] == DBNull.Value)
                    {
                        PH.ImgURL = null;
                    }
                    else
                    {
                        PH.ImgURL = dr["ImgUrl"].ToString();
                    }
                    PH.PrType = (ProductType)Convert.ToByte(dr["PrType"]);
                    PH.OS     = (OsType)Convert.ToByte(dr["OS"]);

                    if (dr["Price"] == DBNull.Value)
                    {
                        PH.price = null;
                    }
                    else
                    {
                        PH.price = (float)(double)(dr["Price"]);
                    }

                    if (dr["DiscountPrice"] == DBNull.Value)
                    {
                        PH.DiscountPrice = null;
                    }
                    else
                    {
                        PH.DiscountPrice = (float)(double)(dr["DiscountPrice"]);
                    }

                    PH.Summery = dr["Summery"].ToString();
                    PH.Sale    = Convert.ToBoolean(dr["Sale"]);

                    phoneList.Add(PH);
                }
                dr.Close();
                con.Close();
            }
            catch (Exception)
            {
                throw;
            }
            return(phoneList);
        }
        public static Phone GetPhoneByID(int id)
        {
            Phone         output = null;
            SqlConnection con    = new SqlConnection(connStr);
            SqlCommand    cmd    = new SqlCommand("GetPhoneByID", con);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter  param;
            SqlDataReader dtr;

            try
            {
                param = new SqlParameter("Id", id);
                cmd.Parameters.Add(param);
                con.Open();
                dtr = cmd.ExecuteReader();

                while (dtr.Read())
                {
                    output           = new Phone();
                    output.Id        = (int)dtr["Id"];
                    output.Name      = dtr["Name"].ToString();
                    output.brand     = (Brands)Convert.ToByte(dtr["Brand"]);
                    output.available = Convert.ToBoolean(dtr["Available"]);

                    if (dtr["PublishDate"] == DBNull.Value)
                    {
                        output.publishDate = null;
                    }
                    else
                    {
                        output.publishDate = Convert.ToDateTime(dtr["PublishDate"]);
                    }

                    if (dtr["ImgUrl"] == DBNull.Value)
                    {
                        output.ImgURL = null;
                    }
                    else
                    {
                        output.ImgURL = dtr["ImgUrl"].ToString();
                    }
                    output.PrType = (ProductType)Convert.ToByte(dtr["PrType"]);
                    output.OS     = (OsType)Convert.ToByte(dtr["OS"]);

                    if (dtr["Price"] == DBNull.Value)
                    {
                        output.price = null;
                    }
                    else
                    {
                        output.price = (float)(double)(dtr["Price"]);
                    }

                    if (dtr["DiscountPrice"] == DBNull.Value)
                    {
                        output.DiscountPrice = null;
                    }
                    else
                    {
                        output.DiscountPrice = (float)(double)(dtr["DiscountPrice"]);
                    }

                    //DBNull.Value ? null : Convert.ToDateTime(reader[3])
                    output.Summery     = dtr["Summery"].ToString();
                    output.Description = dtr["Description"].ToString();
                    output.Sale        = Convert.ToBoolean(dtr["Sale"]);
                }
                dtr.Close();
                con.Close();
            }
            catch (Exception)
            {
                throw;
            }
            return(output);
        }