private void SetValuesToControls() { objTab = new tblTab(); objTab.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)); if (objTab.RowCount > 0) { txtTabName.Text = objTab.AppTabName; ddlParent.SelectedValue = objTab.AppParentID.ToString(); if (objTab.AppWebPageName != "#") { txtWebPageName.Text = objTab.AppWebPageName; } else { txtWebPageName.Text = ""; } ChkIsActive.Checked = objTab.AppIsActive; chkIsAdd.Checked = objTab.AppIsAdd; chkIsEdit.Checked = objTab.AppIsEdit; chkIsDelete.Checked = objTab.AppIsDelete; chkIsMenu.Checked = objTab.AppIsMenu; if (objTab.AppIsShowOnDashboard == true) { chkIsShowOnDashboard.Checked = true; if ((objTab.AppIconPath.ToString() != null)) { imgIconPreview.ImageUrl = (strImagePath) + objTab.AppIconPath; } RegexpImageValid.Enabled = false; reImage.Enabled = false; } else { chkIsShowOnDashboard.Checked = false; RegexpImageValid.Enabled = false; reImage.Enabled = true; } if (!string.IsNullOrEmpty(objTab.AppAddPage)) { txtAddPage.Text = objTab.AppAddPage; chkHasAddOption.Checked = true; } else { txtAddPage.Text = objTab.AppAddPage; chkHasAddOption.Checked = false; } } }
protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { btnSaveAndAddnew.Visible = HasAdd; btnClear.Visible = HasAdd; SetUpDrowDown(); objEncrypt = new clsEncryption(); if ((Request.QueryString.Get("ID") != null)) { try { hdnPKID.Value = objEncrypt.Decrypt(Request.QueryString.Get("ID"), appFunctions.strKey); } catch (Exception ex) { noIdFoundRedirect("Tab.aspx"); } objEncrypt = null; SetValuesToControls(); } if ((Request.QueryString.Get("PID") != null)) { try { intParentId = Convert.ToInt32(objEncrypt.Decrypt(Request.QueryString.Get("PID"), appFunctions.strKey)); } catch (Exception ex) { noIdFoundRedirect("Tab.aspx"); } ddlParent.SelectedValue = intParentId.ToString(); objTab = new tblTab(); objTab.LoadByPrimaryKey(intParentId); objTab.Query.AddResultColumn(tblTab.ColumnNames.AppAddPage); objTab.Query.Load(); ////Set Value To Controls //txtAddPage.Text = objTab.AppAddPage; objTab.Where.WhereClauseReset(); objTab = null; } } }
private bool SaveData() { objTab = new tblTab(); if (!string.IsNullOrEmpty(hdnPKID.Value)) { objTab.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)); } else { objTab.AddNew(); objTab.AppCreatedDate = System.DateTime.Now; objTab.AppCreatedBy = (int)Session[appFunctions.Session.UserID.ToString()]; } objTab.AppTabName = txtTabName.Text; if (objTab.s_AppParentID != ddlParent.SelectedValue.ToString()) { objTab.AppDisplayOrder = objClsCommon.GetNextDisplayOrder("tblTab", tblTab.ColumnNames.AppDisplayOrder, " appParentID = " + ddlParent.SelectedValue); } objTab.AppParentID = Convert.ToInt32(ddlParent.SelectedValue); if (!string.IsNullOrEmpty(txtWebPageName.Text) & txtWebPageName.Text != "#") { tblTab objTemp = new tblTab(); objTemp.Where.AppWebPageName.Value = txtWebPageName.Text; objTemp.Query.AddResultColumn(tblTab.ColumnNames.AppTabID); objTemp.Query.Load(); if (objTemp.RowCount > 0) { if (objTemp.AppTabID != Convert.ToInt32(hdnPKID.Value)) { DInfo.ShowMessage("The Specified Web Page is already allocated to another tab", Enums.MessageType.Error); } } objTab.AppWebPageName = txtWebPageName.Text; } else { objTab.AppWebPageName = "#"; } objTab.AppIsActive = ChkIsActive.Checked; objTab.AppIsAdd = chkIsAdd.Checked; objTab.AppIsEdit = chkIsEdit.Checked; objTab.AppIsDelete = chkIsDelete.Checked; if (chkHasAddOption.Checked == true) { objTab.AppAddPage = txtAddPage.Text; } else { objTab.AppAddPage = ""; } if (chkIsShowOnDashboard.Checked == true) { objTab.AppIsShowOnDashboard = true; if ((FileUploadIcon.HasFile)) { //string fileName = System.IO.Path.GetFileNameWithoutExtension(FileUploadIcon.FileName).ToString(); //string extension = System.IO.Path.GetExtension(FileUploadIcon.FileName).ToString(); //FileUploadIcon.SaveAs(Server.MapPath(strImagePath) + fileName + fileAppend + extension); //try //{ // System.IO.File.Delete(Server.MapPath(".") + Server.MapPath(strImagePath) + objTab.AppIconPath); //} //catch (Exception ex) //{ //} //objTab.AppIconPath = fileName + fileAppend + extension; string strError = ""; string Time = Convert.ToString(DateTime.Now.Month) + Convert.ToString(DateTime.Now.Day) + Convert.ToString(DateTime.Now.Year) + Convert.ToString(DateTime.Now.Hour) + Convert.ToString(DateTime.Now.Minute) + Convert.ToString(DateTime.Now.Second); string strPath = objClsCommon.FileUpload_Images(FileUploadIcon.PostedFile, txtTabName.Text.Trim().Replace(" ", "_") + "_" + Time, "Uploads/TabImages/", ref strError, 0, objTab.AppIconPath); if (strError == "") { objTab.AppIconPath = strPath; } else { DInfo.ShowMessage(strError, Enums.MessageType.Error); return(false); } } } else { objTab.AppIsShowOnDashboard = false; objTab.AppIconPath = ""; } ////If IsMenu Is True if (chkIsMenu.Checked == true) { ////Make All Others IsMenu To False tblTab objTemp = new tblTab(); objTemp.updateIsMenu(); objTab.AppIsMenu = true; } else { objTab.AppIsMenu = false; } objTab.Save(); objTab = null; return(true); }
protected void dgvGridView_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { if (!string.IsNullOrEmpty(e.CommandArgument.ToString())) { clsEncryption objEncrypt = new clsEncryption(); int intHiddenPKID = 0; if (!string.IsNullOrEmpty(hdnPKID.Value)) { intHiddenPKID = Convert.ToInt32(hdnPKID.Value); } objCommon = new clsCommon(); hdnPKID.Value = e.CommandArgument.ToString(); if (e.CommandName == "ListChildMenus") { Response.Redirect("Tab.aspx?ID=" + objEncrypt.Encrypt(hdnPKID.Value, appFunctions.strKey), true); } //else if (e.CommandName == "Edit") //{ // Response.Redirect("TabDetail.aspx?ID=" + objEncrypt.Encrypt(hdnPKID.Value, appFunctions.strKey), true); //} else if (e.CommandName == "Up") { LinkButton inkButton = (LinkButton)e.CommandSource; GridViewRow drCurrent = (GridViewRow)inkButton.Parent.Parent; if (drCurrent.RowIndex > 0) { GridViewRow drUp = dgvGridView.Rows[drCurrent.RowIndex - 1]; objCommon.SetDisplayOrder("tblTab", tblTab.ColumnNames.AppTabID, tblTab.ColumnNames.AppDisplayOrder, (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[0], (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[5], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[0], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[5]); hdnPKID.Value = intHiddenPKID.ToString(); LoadDataGrid(false, false); objCommon = null; } hdnPKID.Value = intHiddenPKID.ToString(); } else if (e.CommandName == "Down") { LinkButton lnkButton = (LinkButton)e.CommandSource; GridViewRow drCurrent = (GridViewRow)lnkButton.Parent.Parent; if (drCurrent.RowIndex < dgvGridView.Rows.Count - 1) { GridViewRow drUp = dgvGridView.Rows[drCurrent.RowIndex + 1]; objCommon.SetDisplayOrder("tblTab", tblTab.ColumnNames.AppTabID, tblTab.ColumnNames.AppDisplayOrder, (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[0], (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[5], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[0], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[5]); hdnPKID.Value = intHiddenPKID.ToString(); LoadDataGrid(false, false); objCommon = null; } hdnPKID.Value = intHiddenPKID.ToString(); } else if (e.CommandName == "IsActive") { objtab = new tblTab(); objtab.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)); if (objtab.AppIsActive == true) { objtab.AppIsActive = false; } else if (objtab.AppIsActive == false) { objtab.AppIsActive = true; } objtab.Save(); LoadDataGrid(false, false, "", ""); } else if (e.CommandName == "IsAdd") { objtab = new tblTab(); objtab.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)); if (objtab.AppIsAdd == true) { objtab.AppIsAdd = false; } else if (objtab.AppIsAdd == false) { objtab.AppIsAdd = true; } objtab.Save(); LoadDataGrid(false, false, "", ""); } else if (e.CommandName == "IsEdit") { objtab = new tblTab(); objtab.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)); if (objtab.AppIsEdit == true) { objtab.AppIsEdit = false; } else if (objtab.AppIsEdit == false) { objtab.AppIsEdit = true; } objtab.Save(); LoadDataGrid(false, false, "", ""); } else if (e.CommandName == "IsDelete") { objtab = new tblTab(); objtab.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)); if (objtab.AppIsDelete == true) { objtab.AppIsDelete = false; } else if (objtab.AppIsDelete == false) { objtab.AppIsDelete = true; } objtab.Save(); LoadDataGrid(false, false, "", ""); } else if (e.CommandName == "IsDashbord") { objtab = new tblTab(); objtab.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)); if (objtab.AppIsShowOnDashboard == true) { objtab.AppIsShowOnDashboard = false; } else if (objtab.AppIsShowOnDashboard == false) { objtab.AppIsShowOnDashboard = true; } objtab.Save(); LoadDataGrid(false, false, "", ""); } } }