public List <clsPhone> GetPhoneListByType(string Type) { Dictionary <string, object> par = new Dictionary <string, object>(1); par.Add("Type", Type); DataTable lcResult = ClsDBConnection.GetDataTable("SELECT id, IMEI, name, item_price, description, color, " + "type, availability, phone_condition, category_id, warrenty, image FROM tbl_all_products " + "where type = @Type", par); List <clsPhone> lcPhones = new List <clsPhone>(); foreach (DataRow dr in lcResult.Rows) { lcPhones.Add(new clsPhone { ID = (int)dr[0], IMEI = (string)dr[1], Name = (string)dr[2], ItemPrice = (decimal)dr[3], Description = (string)dr[4], Color = (string)dr[5], Type = (string)dr[6], Availability = (string)dr[7], Condition = (dr[8] == DBNull.Value) ? string.Empty : (string)dr[8], CategoryID = (int)dr[9], Warrenty = (dr[10] == DBNull.Value) ? string.Empty : (string)dr[10], Image = (string)dr[11] }); } return(lcPhones); }
public clsPhone GetPhoneDetailsById(string ID) { Dictionary <string, object> par = new Dictionary <string, object>(1); par.Add("ID", ID); DataTable lcResult = ClsDBConnection.GetDataTable("SELECT * FROM tbl_all_products WHERE id = @ID", par); if (lcResult.Rows.Count > 0) { return new clsPhone() { Name = (string)lcResult.Rows[0]["name"], ID = (int)lcResult.Rows[0]["id"], IMEI = (string)lcResult.Rows[0]["IMEI"], ItemPrice = (decimal)lcResult.Rows[0]["item_price"], Description = (string)lcResult.Rows[0]["description"], Color = (string)lcResult.Rows[0]["color"], Type = (string)lcResult.Rows[0]["type"], Availability = (string)lcResult.Rows[0]["availability"], Condition = lcResult.Rows[0]["phone_condition"] != DBNull.Value ? (string)lcResult.Rows[0]["phone_condition"] : "", CategoryID = (int)lcResult.Rows[0]["category_id"], Warrenty = lcResult.Rows[0]["warrenty"] != DBNull.Value ? (string)lcResult.Rows[0]["warrenty"] : "", Image = (string)lcResult.Rows[0]["Image"] } } ; else { return(null); } }
private bool IsPhoneBooked(int productId) { DataTable lcResult = ClsDBConnection.GetDataTable("SELECT * FROM tbl_orders where product_id = " + productId + "", null); if (lcResult.Rows.Count > 0) { return(true); } else { return(false); } }
public List <clsPhoneCategories> GetPhoneCategories() { DataTable lcResult = ClsDBConnection.GetDataTable("SELECT id, name FROM tbl_categories", null); List <clsPhoneCategories> lcPhoneCategories = new List <clsPhoneCategories>(); foreach (DataRow dr in lcResult.Rows) { lcPhoneCategories.Add(new clsPhoneCategories { Text = (string)dr[1], Value = (int)dr[0], }); } return(lcPhoneCategories); }
public List <clsOrders> GetPhoneCompletedOrders() { DataTable lcResult = ClsDBConnection.GetDataTable("SELECT tbl_orders.email, tbl_orders.amount, " + "tbl_orders.id, tbl_all_products.`name`, DATE_FORMAT(tbl_orders.created_at,'%m/%d/%Y') as date" + " FROM tbl_orders INNER JOIN tbl_all_products ON tbl_orders.product_id = tbl_all_products.id WHERE" + " tbl_orders.`status` = 1", null); List <clsOrders> lcPhoneOrders = new List <clsOrders>(); foreach (DataRow dr in lcResult.Rows) { lcPhoneOrders.Add(new clsOrders { Email = (string)dr[0], Amount = (string)dr[1], ID = (int)dr[2], ProductName = (string)dr[3], Date = (string)dr[4] }); } return(lcPhoneOrders); }