protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (CatID != 0) { ProductCategories cat = new ProductCategories(); cat.LoadByPrimaryKey(CatID); uiTextBoxName.Text = cat.NameEn; uiTextBoxDesc.Text = cat.DescriptionEn; uiImageMain.ImageUrl = cat.ImagePath; uiPanelEdit.Visible = true; } else if(AddNew == 1) uiPanelEdit.Visible = true; else { uiPanelEdit.Visible = false; } // Bind Categories from the DB. FillCategories(); } }
private string getCatName() { ProductCategories Cats = new ProductCategories(); Cats.LoadByPrimaryKey(int.Parse(Session["CategoryID"].ToString())); return Cats.NameEn; }
protected void uiLinkButtonSave_Click(object sender, EventArgs e) { ProductCategories cat = new ProductCategories(); if (AddNew != 0) cat.AddNew(); else cat.LoadByPrimaryKey(CatID); cat.NameEn = uiTextBoxName.Text; cat.DescriptionEn = uiTextBoxDesc.Text; if (!IsParent && ParentCatID !=0) { cat.CategoryParentID = ParentCatID; } if (uiFileUploadImg.HasFile) { string filepath = "/admin/UploadedFiles/cats/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + "_" + uiFileUploadImg.FileName; uiFileUploadImg.SaveAs(Server.MapPath("~" + filepath)); cat.ImagePath= filepath; } cat.Save(); FillCategories(); uiPanelEdit.Visible = false; clearFields(); }
protected void uiLinkButtonDelete_Click(object sender, EventArgs e) { ProductCategories cat = new ProductCategories(); cat.LoadByPrimaryKey(CatID); cat.MarkAsDeleted(); cat.Save(); FillCategories(); uiPanelEdit.Visible = false; }