protected void uiGridViewCats_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditCat") { MainCat objData = new MainCat(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); uiTextBoxEnName.Text = objData.NameEng; uiTextBoxArName.Text = objData.NameAr; uiPanelAllCats.Visible = false; uiPanelEditCat.Visible = true; CurrentMainCat = objData; BindCats(); } else if (e.CommandName == "DeleteCat") { try { MainCat objData = new MainCat(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); objData.MarkAsDeleted(); objData.Save(); CurrentMainCat = null; BindCats(); } catch (Exception ex) { uipanelError.Visible = true; } } }
protected void uiLinkButtonOK_Click(object sender, EventArgs e) { MainCat cat = new MainCat(); if (CurrentMainCat == null) { cat.AddNew(); cat.IsPartySupplier = true; } else cat = CurrentMainCat; cat.NameEng = uiTextBoxEnName.Text; cat.NameAr = uiTextBoxArName.Text; 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.TopLevelCatID = Convert.ToInt32(uiDropDownListTLCats.SelectedValue); cat.Save(); ClearFields(); CurrentMainCat = null; uiPanelEditCat.Visible = false; uiPanelAllCats.Visible = true; BindCats(); }