protected void dgvPropertyPreValue_RowCommand(object sender, GridViewCommandEventArgs e) { if (!string.IsNullOrEmpty(e.CommandArgument.ToString())) { objCommon = new clsCommon(); if (e.CommandName == "Edit") { hdnPropertyPreValueId.Value = e.CommandArgument.ToString(); SetPropertyPreValueValuesToControls(); } else if (e.CommandName == "Up") { LinkButton inkButton = (LinkButton)e.CommandSource; GridViewRow drCurrent = (GridViewRow)inkButton.Parent.Parent; if (drCurrent.RowIndex > 0) { GridViewRow drUp = dgvPropertyPreValue.Rows[drCurrent.RowIndex - 1]; objCommon.SetDisplayOrder("tblPropertyPreValue", tblPropertyPreValue.ColumnNames.AppPropertyPreValueID, tblPropertyPreValue.ColumnNames.AppDisplayOrder, (int)dgvPropertyPreValue.DataKeys[drCurrent.RowIndex].Values[0], (int)dgvPropertyPreValue.DataKeys[drCurrent.RowIndex].Values[1], (int)dgvPropertyPreValue.DataKeys[drUp.RowIndex].Values[0], (int)dgvPropertyPreValue.DataKeys[drUp.RowIndex].Values[1]); LoadPropertyPreValueData(false, false); objCommon = null; } } else if (e.CommandName == "Down") { LinkButton lnkButton = (LinkButton)e.CommandSource; GridViewRow drCurrent = (GridViewRow)lnkButton.Parent.Parent; if (drCurrent.RowIndex < dgvPropertyPreValue.Rows.Count - 1) { GridViewRow drUp = dgvPropertyPreValue.Rows[drCurrent.RowIndex + 1]; objCommon.SetDisplayOrder("tblPropertyPreValue", tblPropertyPreValue.ColumnNames.AppPropertyPreValueID, tblPropertyPreValue.ColumnNames.AppDisplayOrder, (int)dgvPropertyPreValue.DataKeys[drCurrent.RowIndex].Values[0], (int)dgvPropertyPreValue.DataKeys[drCurrent.RowIndex].Values[1], (int)dgvPropertyPreValue.DataKeys[drUp.RowIndex].Values[0], (int)dgvPropertyPreValue.DataKeys[drUp.RowIndex].Values[1]); LoadPropertyPreValueData(false, false); objCommon = null; } } else if (e.CommandName == "IsActive") { objPropertyPreValue = new tblPropertyPreValue(); if (objPropertyPreValue.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()))) { if (objPropertyPreValue.AppIsActive == true) { objPropertyPreValue.AppIsActive = false; } else if (objPropertyPreValue.AppIsActive == false) { objPropertyPreValue.AppIsActive = true; } objPropertyPreValue.Save(); LoadPropertyPreValueData(false, false); } objPropertyPreValue = null; } } }
private bool SavePropertyPreValueData() { if (hdnPKID.Value != "") { objCommon = new clsCommon(); if (objCommon.IsRecordExists("tblPropertyPreValue", tblPropertyPreValue.ColumnNames.AppPreValue, tblPropertyPreValue.ColumnNames.AppPropertyPreValueID, txtPreValue.Text, hdnPropertyPreValueId.Value, tblPropertyPreValue.ColumnNames.AppPropertyID + "=" + hdnPKID.Value)) { DInfoPropertyPreValue.ShowMessage("Pre-Value alredy exits.", Enums.MessageType.Error); return(false); } objPropertyPreValue = new tblPropertyPreValue(); if (!string.IsNullOrEmpty(hdnPropertyPreValueId.Value) && hdnPropertyPreValueId.Value != "") { objPropertyPreValue.LoadByPrimaryKey(Convert.ToInt32(hdnPropertyPreValueId.Value)); } else { objPropertyPreValue.AddNew(); objPropertyPreValue.s_AppCreatedBy = Session[appFunctions.Session.UserID.ToString()].ToString(); objPropertyPreValue.AppCreatedDate = DateTime.Now; objPropertyPreValue.AppDisplayOrder = objCommon.GetNextDisplayOrder("tblPropertyPreValue", tblPropertyPreValue.ColumnNames.AppDisplayOrder, tblPropertyPreValue.ColumnNames.AppPropertyID + "=" + hdnPKID.Value); } objPropertyPreValue.s_AppPropertyID = hdnPKID.Value; objPropertyPreValue.AppPreValue = txtPreValue.Text; objPropertyPreValue.AppIsActive = chkPropertyPreValueIsActive.Checked; objPropertyPreValue.Save(); objPropertyPreValue = null; objCommon = null; return(true); } else { return(false); } }