예제 #1
0
        public static List <Suppliers_Products> GetProductsSuppliers(string P_name, string mark, string style, double inch)
        {
            List <Suppliers_Products> Suppliers = new List <Suppliers_Products>();
            string        CS  = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
            SqlConnection con = new SqlConnection(CS);
            SqlCommand    cmd = new SqlCommand("Get_Product_Suppliers", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@P_name", SqlDbType.NVarChar).Value = P_name;
            cmd.Parameters.Add("@Mark", SqlDbType.NVarChar).Value   = mark;
            cmd.Parameters.Add("@Style", SqlDbType.NVarChar).Value  = style;
            cmd.Parameters.Add("@Inch", SqlDbType.Decimal).Value    = inch;
            con.Open();
            SqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                Suppliers_Products supplier = new Suppliers_Products();
                supplier.Supplier_Name = rdr["Supplier_Name"].ToString();
                supplier.Purchase_Date = Convert.ToDateTime(rdr["Purchase_Date"]);
                supplier.Price         = Convert.ToDouble(rdr["Price"]);
                supplier.Amount        = Convert.ToDecimal(rdr["amount"]);
                Suppliers.Add(supplier);
            }
            rdr.Close();
            con.Close();
            return(Suppliers);
        }
예제 #2
0
        public static List <Suppliers_Products> Get_Supplier_Products(string supplier_name)
        {
            List <Suppliers_Products> Supplier_ProductsList = new List <Suppliers_Products>();
            string        CS  = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
            SqlConnection con = new SqlConnection(CS);
            SqlCommand    cmd = new SqlCommand("Get_Supplier_Products", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@S_name", SqlDbType.NVarChar).Value = supplier_name;
            con.Open();
            SqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                Suppliers_Products product = new Suppliers_Products();
                product.Purchase_Date = Convert.ToDateTime(rdr["Purchase_Date"]);
                if (rdr["Mark"].ToString() != "Not found" && rdr["Style"].ToString() == "Not found")
                {
                    product.Product_Name = rdr["P_Name"].ToString() + "- ماركة " + rdr["Mark"].ToString() + "- " + Convert.ToDouble(rdr["Inch"].ToString()) + " بوصه";
                }
                else if (rdr["Style"].ToString() != "Not found")
                {
                    product.Product_Name = rdr["P_Name"].ToString() + "- ماركة " + rdr["Mark"].ToString() + "- " + Convert.ToDouble(rdr["Inch"].ToString()) + " بوصه"
                                           + "- طراز" + rdr["Style"].ToString();
                }
                else
                {
                    product.Product_Name = rdr["P_Name"].ToString();
                }
                product.Price             = Convert.ToDouble(rdr["Price"]);
                product.Amount            = Convert.ToInt32(rdr["Amount"]);
                product.Returned_Products = Convert.ToInt32(rdr["Returned_Products"]);
                product.Return_Date       = rdr["Return_Date"] is DBNull ? new DateTime(0001, 01, 01) : Convert.ToDateTime(rdr["Return_Date"]);
                Supplier_ProductsList.Add(product);
            }
            rdr.Close();
            con.Close();
            return(Supplier_ProductsList);
        }