Beispiel #1
0
        public static int UpdateStatus(int id, string state)
        {
            SqlCommand cmd = new SqlCommand("update [Order] set state=@state where Order_id =@id");

            cmd.Parameters.AddWithValue("@state", state);
            cmd.Parameters.AddWithValue("@id", id);
            return(DBlayer.Dml(cmd));
        }
        //delete

        public static int remove(int id)

        {
            SqlCommand cmd = new SqlCommand("delete from Category where Category_id=@id");

            cmd.Parameters.AddWithValue("@id", id);
            return(DBlayer.Dml(cmd));
        }
        //insert

        public static int add(string name)

        {
            SqlCommand cmd = new SqlCommand("insert into Category values(@name)");

            cmd.Parameters.AddWithValue("@name", name);
            return(DBlayer.Dml(cmd));
        }
        public static int insert(int cus_id, int prod_id)
        {
            SqlCommand cmd = new SqlCommand("insert into  cart values(@cus_id,@prod_id,@mount)");

            cmd.Parameters.AddWithValue("@cus_id", cus_id);
            cmd.Parameters.AddWithValue("@prod_id", prod_id);
            cmd.Parameters.AddWithValue("@mount", 1);
            return(DBlayer.Dml(cmd));
        }
        //nada
        public static void DecreaseQuantity(int id, int quantity)
        {
            SqlCommand cmd = new SqlCommand("UPDATE Product set Prod_Quantity=(Select Prod_Quantity From product where prod_id=@id)-@quantity where prod_id = @id");

            cmd.Parameters.AddWithValue("@id", id);
            cmd.Parameters.AddWithValue("@quantity", quantity);
            //cmd.Parameters.Add("@kkkjk",SqlDbType.UniqueIdentifier,4,jjjjj)
            DBlayer.Dml(cmd);
        }
Beispiel #6
0
        public static int approvingorder(int orderid)
        {
            SqlCommand cmd = new SqlCommand("update [Order] set state='Approved' where  [Order].order_id=@id  and[Order].state = 'pending'");

            cmd.Parameters.AddWithValue("@id", orderid);


            return(DBlayer.Dml(cmd));
        }
Beispiel #7
0
        public static int insert(int UserID)
        {
            SqlCommand command = new SqlCommand("insert into [Order] (Cust_id,Packing_date,state) values(@custid ,@pkdate,@state)");

            command.Parameters.AddWithValue("@custid", UserID);
            command.Parameters.AddWithValue("@pkdate", DateTime.Now);
            command.Parameters.AddWithValue("@state", "pending");
            return(DBlayer.Dml(command));
        }
        //update
        public static int edit(int id, string name)

        {
            SqlCommand cmd = new SqlCommand("update Category set Category_name=@name where Category_id=@id");

            cmd.Parameters.AddWithValue("@name", name);
            cmd.Parameters.AddWithValue("@id", id);
            return(DBlayer.Dml(cmd));
        }
        public static int empty(int cus_id)
        {
            SqlCommand cmd = new SqlCommand("delete from cart  where customer_id=@c");

            cmd.Parameters.AddWithValue("@c", cus_id);


            return(DBlayer.Dml(cmd));
        }
        //update
        public static int editstatus(int id, string newStatus)

        {
            SqlCommand cmd = new SqlCommand("update Customer  set State=@state where  Cust_id=@id");

            cmd.Parameters.AddWithValue("@state", newStatus);
            cmd.Parameters.AddWithValue("@id", id);

            return(DBlayer.Dml(cmd));
        }
        public static int change_quantity(int cus_id, int prod_id, int quantity)
        {
            SqlCommand cmd = new SqlCommand("update cart set quantity= @mount where customer_id=@cus_id and prod_id= @prod_id ");

            cmd.Parameters.AddWithValue("@cus_id", cus_id);
            cmd.Parameters.AddWithValue("@prod_id", prod_id);
            cmd.Parameters.AddWithValue("@mount", quantity);

            return(DBlayer.Dml(cmd));
        }
Beispiel #12
0
        public static int insertOrderDetails(int prodid, int orderid, int quantity)
        {
            SqlCommand cmd = new SqlCommand("insert into [OrderItem] values(@prod,@order,@quantity)");

            cmd.Parameters.AddWithValue("@prod", prodid);
            cmd.Parameters.AddWithValue("@order", orderid);
            cmd.Parameters.AddWithValue("@quantity", quantity);
            Cart_products.trunccart();
            return(DBlayer.Dml(cmd));
        }
        public static int  remove(int cus_id, int prod_id)
        {
            SqlCommand cmd = new SqlCommand("delete from cart  where customer_id=@c and prod_id=@p");

            cmd.Parameters.AddWithValue("@c", cus_id);
            cmd.Parameters.AddWithValue("@p", prod_id);


            return(DBlayer.Dml(cmd));
        }
Beispiel #14
0
        public static int insertprice(int orderid)
        {
            DataTable dt = totalPrice(orderid);

            SqlCommand cmd = new SqlCommand("update[order] set cost=@price,Deliver_date=@date where Order_id=@id");

            cmd.Parameters.AddWithValue("@price", decimal.Parse(dt.Rows[0][0].ToString()));
            cmd.Parameters.AddWithValue("@date", DateTime.Now.AddDays(15));
            cmd.Parameters.AddWithValue("@id", orderid);

            return(DBlayer.Dml(cmd));
        }
        //insert product
        public static int Add(string name, string Desc, int price, int quantity, string img1, int catid)

        {
            SqlCommand cmd = new SqlCommand("insert into product (Prod_name,Prod_desc,Prod_price,Prod_img,Category_id,Prod_quantity) Values(@name,@desc,@price,@img,@catid,@quantity)");

            cmd.Parameters.AddWithValue("@name", name);
            cmd.Parameters.AddWithValue("@desc", Desc);
            cmd.Parameters.AddWithValue("@price", price);
            cmd.Parameters.AddWithValue("@img", img1);
            cmd.Parameters.AddWithValue("@catid", catid);
            cmd.Parameters.AddWithValue("@quantity", quantity);

            return(DBlayer.Dml(cmd));
        }
        //Samar
        //update product
        public static int edit(int id, string name, string Desc, int price, int quantity, string img1, string prom, int catid)

        {
            SqlCommand cmd = new SqlCommand("update product set Prod_name=@name,Prod_Desc=@desc,prod_price=@price,prod_img=@img,prod_quantity=@quantity,Category_id=@catid,promotion=@prom where prod_id=@id");

            cmd.Parameters.AddWithValue("@name", name);
            cmd.Parameters.AddWithValue("@desc", Desc);
            cmd.Parameters.AddWithValue("@price", price);
            cmd.Parameters.AddWithValue("@prom", prom);
            cmd.Parameters.AddWithValue("@img", img1);
            cmd.Parameters.AddWithValue("@catid", catid);
            cmd.Parameters.AddWithValue("@quantity", quantity);
            cmd.Parameters.AddWithValue("@id", id);
            return(DBlayer.Dml(cmd));
        }
        //Update or delete or promotion
        public static int editprom(string prom, int id)
        {
            SqlCommand cmd = new SqlCommand("Update Product set promotion=@prom where prod_id=@id");

            if (prom == "NULL")
            {
                cmd.Parameters.AddWithValue("@prom", DBNull.Value);
            }
            else
            {
                cmd.Parameters.AddWithValue("@prom", prom);
            }
            cmd.Parameters.AddWithValue("@id", id);

            return(DBlayer.Dml(cmd));
        }
Beispiel #18
0
        public static int change(int id, string fname, string lname, string username, string mail, string address, string phone)
        {
            SqlCommand cmd = new SqlCommand("update Customer set Cust_fname =@n,Cust_lname=@n2,Cust_username=@n3 ,Cust_mail=@n4,Cust_address=@n5,Cust_phone=@n6 where Cust_id=@id");

            cmd.Parameters.AddWithValue("@id", id);
            cmd.Parameters.AddWithValue("@n", fname);
            cmd.Parameters.AddWithValue("@n2", lname);
            cmd.Parameters.AddWithValue("@n3", username);
            cmd.Parameters.AddWithValue("@n4", mail);
            cmd.Parameters.AddWithValue("@n5", address);
            cmd.Parameters.AddWithValue("@n6", phone);



            return(DBlayer.Dml(cmd));
        }
Beispiel #19
0
        public static int insert(string national_id, int isadmin, string password, string fname, string lname, string email, string uname, string pic, string address, string state, string phone, int code)
        {
            SqlCommand command = new SqlCommand("insert into [Customer] (Cust_fName,Cust_lName,Cust_mail,Cust_username,Cust_ssnimg,Cust_address,state,Cust_phone,Cust_zipCode,Cust_pass,isAdmin,Cust_ssn) values(@Fname ,@Lname,@mail,@uname,@pict,@address,@state,@phone,@zipcode,@pass,@isAdmin,@nationalId)");

            command.Parameters.AddWithValue("Fname", fname);
            command.Parameters.AddWithValue("Lname", lname);
            command.Parameters.AddWithValue("mail", email);
            command.Parameters.AddWithValue("uname", uname);
            command.Parameters.AddWithValue("pict", pic);
            command.Parameters.AddWithValue("address", address);
            command.Parameters.AddWithValue("state", state);
            command.Parameters.AddWithValue("phone", phone);
            command.Parameters.AddWithValue("pass", password);
            command.Parameters.AddWithValue("nationalId", national_id);
            command.Parameters.AddWithValue("isAdmin", isadmin);
            command.Parameters.AddWithValue("zipcode", code);
            return(DBlayer.Dml(command));
        }