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)); }
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)); }
//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)); }
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)); }
//select all public static DataTable getAll() { SqlCommand cmd = new SqlCommand("select * from Category"); return(DBlayer.Sel(cmd)); }
public static DataTable getPendingUsers() { SqlCommand cmd = new SqlCommand("select * from Customer where State='pending' "); return(DBlayer.Sel(cmd)); }
//select public static DataTable getBlockedUsers() { SqlCommand cmd = new SqlCommand("select * from Customer where State='blocked' "); return(DBlayer.Sel(cmd)); }
public static DataTable getUsers() { SqlCommand cmd = new SqlCommand("select * from Customer where IsAdmin=0 "); return(DBlayer.Sel(cmd)); }
//samar public static DataTable numofpending() { SqlCommand cmd = new SqlCommand("Select count(order_id) from [order] where state='Pending'"); return(DBlayer.Sel(cmd)); }
public static void trunccart() { SqlCommand cmd = new SqlCommand("truncate table cart"); DBlayer.Truncate(cmd); }
public static DataTable getProdPrice() { SqlCommand cmd = new SqlCommand("select Prod_price,Prod_id from Product where prod_quantity!=0 "); return(DBlayer.Sel(cmd)); }
public static DataTable getPromotions() { SqlCommand cmd = new SqlCommand("select * from Product where promotion is not null "); return(DBlayer.Sel(cmd)); }
public static DataTable getAll2() { SqlCommand cmd = new SqlCommand("select * from Product"); return(DBlayer.Sel(cmd)); }
public static DataTable getAll() { SqlCommand cmd = new SqlCommand("select * from Product where prod_quantity!=0"); return(DBlayer.Sel(cmd)); }