protected void uiGridViewCats_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditCat") { TopLevelCat objData = new TopLevelCat(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); uiTextBoxEnName.Text = objData.NameEng; uiTextBoxArName.Text = objData.NameAr; uiPanelAllCats.Visible = false; uiPanelEditCat.Visible = true; CurrentTopCat = objData; BindCats(); } else if (e.CommandName == "DeleteCat") { try { TopLevelCat objData = new TopLevelCat(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); objData.MarkAsDeleted(); objData.Save(); CurrentTopCat = null; BindCats(); } catch (Exception ex) { uipanelError.Visible = true; } } }
protected void uiLinkButtonOK_Click(object sender, EventArgs e) { TopLevelCat cat = new TopLevelCat(); if (CurrentTopCat == null) { cat.AddNew(); cat.IsPartySupplier = false; } else cat = CurrentTopCat; cat.NameEng = uiTextBoxEnName.Text; cat.NameAr = uiTextBoxArName.Text; cat.IsPartySupplier = false; if (uiFileUploadImage.HasFile) { string filepath = "/images/Category/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + "_" + uiFileUploadImage.FileName; uiFileUploadImage.SaveAs(Server.MapPath("~" + filepath)); cat.ImagePath = filepath; } if (uiFileUploadHover.HasFile) { string filepath = "/images/Category/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + "_" + uiFileUploadHover.FileName; uiFileUploadHover.SaveAs(Server.MapPath("~" + filepath)); cat.HoverImage = filepath; } cat.Save(); ClearFields(); CurrentTopCat = null; uiPanelEditCat.Visible = false; uiPanelAllCats.Visible = true; BindCats(); }