internal bool InsertNewItem(Products ins, int Type, string admin) { base.com.CommandText = "spInsertProductbyType"; base.com.Parameters.AddWithValue("_Name", ins.Name); base.com.Parameters.AddWithValue("_Price", ins.Price); base.com.Parameters.AddWithValue("_Categ", Type); base.com.Parameters.AddWithValue("_UnitCode", ins.UnitCode); base.com.Parameters.AddWithValue("_ImgUrl", ins.ImgUrl); base.com.Parameters.AddWithValue("_ImgWidth", ins.ImgWidth); base.com.Parameters.AddWithValue("_ImgHeight", ins.ImgHeight); base.com.Parameters.AddWithValue("_Specs", ins.Specs); base.com.Parameters.AddWithValue("_DateCreated", ins.DateCreated); base.com.Parameters.AddWithValue("_DateUpdated", ins.DateUpdated); base.com.Parameters.AddWithValue("_EmpID", ins.EmpID); base.com.Parameters.AddWithValue("_ProdCode", ins.ProdCode); base.com.Parameters.AddWithValue("_ColorCode", ins.ColorCode); base.com.Parameters.AddWithValue("_IMEI", ""); base.com.Parameters.AddWithValue("_Active", ins.Active); base.com.Parameters.AddWithValue("_CreatedBy", admin); //int res = Convert.ToInt32(base.com.ExecuteScalar()); int res; try { res = Convert.ToInt32(base.com.ExecuteScalar()); } catch (Exception ee) { //throw new Exception("Insert Data Failed"); throw new Exception(ee.Message); } finally { closeConnection(); } return (res > 0); }
public static bool UpdatedSelItem(Products ins, int Type, string admin) { var dal = new ProductsDAL(); return dal.UpdatedSelItem(ins, Type, admin); }
public static bool InsertNewItem(Products ins, int Type, string admin) { var dal = new ProductsDAL(); return dal.InsertNewItem(ins, Type, admin); }
public static List<Products> GetPhoneByTypeByKiosk(int type, int kioskid) { var dal = new ProductsDAL(); var collection = new List<Products>(); foreach (DataRow row in dal.GetPhoneByTypeByKiosk(type, kioskid).Rows) { var instance = new Products(); instance.Bind2(row); collection.Add(instance); } return collection; }
public static List<Products> GetAllTablets() { var dal = new ProductsDAL(); var collection = new List<Products>(); foreach(DataRow row in dal.GetAllTablets().Rows){ var instance = new Products(); instance.Bind(row); collection.Add(instance); } return collection; }
public static List<Products> GetAllProductsFilterByType(int type, string filter) { var dal = new ProductsDAL(); var collection = new List<Products>(); foreach (DataRow row in dal.GetAllProductsFilterByType(type, filter).Rows) { var instance = new Products(); instance.Bind(row); collection.Add(instance); } return collection; }
private void UpdateProMethod(Products ins, int Type) { bool isUpdated = Products.UpdatedSelItem(ins, Type, GlobalAccess.EmpID); if (isUpdated) { //MessageBox("Products has successfuly updated"); (Master as Frame).PopUp("Products has successfuly updated"); int type = Convert.ToInt32(hdnType.Value); callDataGrid(type); mvMain.ActiveViewIndex = 0; // back to normal clearFields(); } else { //MessageBox("Data is not updated, check your fields"); (Master as Frame).PopUp("Data is not updated, check your fields"); } }
protected void btnSave_Click(object sender, EventArgs e) { int id = Convert.ToInt32(hdnID.Value); if (rblUpload.SelectedValue == "1" && id == 0) { string val = Session["ImageFullPath"] as string; if(val == null || val == string.Empty){ (Master as Frame).PopUp("No Selected Images"); return; } } try { Products ins = new Products(); ins.ID = id; ins.Name = tbName.Text.ToUpper().Trim(); ins.Price = Convert.ToDecimal(tbPrice.Text.Trim()); int Type = Convert.ToInt32(ddlProductType.SelectedValue); ins.UnitCode = ddlUnitType.SelectedValue; if (rblUpload.SelectedValue == "1") { ins.ImgUrl = Session["ImageFullPath"] as string; } else { ins.ImgUrl = tbImgURL.Text.Trim(); } ins.ImgWidth = Convert.ToInt32(tbWidth.Text.Trim()); ins.ImgHeight = Convert.ToInt32(tbHeight.Text.Trim()); ins.Specs = tbSpecs.Text.ToUpper(); ins.DateCreated = DateTime.Now; ins.DateUpdated = DateTime.Now; ins.EmpID = GlobalAccess.EmpID; ins.ColorCode = ddlColorType.SelectedValue; //ins.IMEI = tbIMEI.Text.Trim(); ins.ProdCode = tbProdCode.Text.ToUpper(); ins.Active = cbActive.Checked ? "t":"f" ; ins.Name = ins.Name.Trim(); // concatinate colorcode to prodname ins.Name = ChangeProdName(ins.ColorCode, ins.Name); // if (id == 0)// for Adding { InsertProdMethod(ins, Type); } else // for Updating { int isVariantCreation = Convert.ToInt32(hdnIsVariant.Value); if (isVariantCreation == 0) // if edit mode { UpdateProMethod(ins, Type); } else {// if create variant mode InsertProdMethod(ins, Type); } } } catch (Exception ee) { (Master as Frame).PopUp(ee.Message); } }