private bool SaveData()
 {
     objCommon = new clsCommon();
     if (objCommon.IsRecordExists("tblSubCategory", tblSubCategory.ColumnNames.AppSubCategory, tblSubCategory.ColumnNames.AppSubCategoryID, txtSubCategoryName.Text, hdnPKID.Value, tblSubCategory.ColumnNames.AppCategoryID + "=" + ddlCategory.SelectedValue))
     {
         DInfo.ShowMessage("Sub Category Name alredy exits.", Enums.MessageType.Error);
         return(false);
     }
     objSubCategory = new tblSubCategory();
     if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "")
     {
         objSubCategory.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value));
     }
     else
     {
         objSubCategory.AddNew();
         objSubCategory.s_AppCreatedBy  = Session[appFunctions.Session.UserID.ToString()].ToString();
         objSubCategory.AppDisplayOrder = objCommon.GetNextDisplayOrder("tblSubCategory", tblSubCategory.ColumnNames.AppDisplayOrder, tblSubCategory.ColumnNames.AppCategoryID + "=" + ddlCategory.SelectedValue);
         // objSubCategory.s_AppCreatedDate = FormatDateString(DateTime.Now.ToString(strInputDateFormat), strInputDateFormat, strOutputDateFormat);
         objSubCategory.AppCreatedDate = DateTime.Now;
     }
     objSubCategory.s_AppSubCategory = txtSubCategoryName.Text;
     objSubCategory.s_AppCategoryID  = ddlCategory.SelectedValue;
     objSubCategory.AppIsActive      = chkIsActive.Checked;
     objSubCategory.Save();
     intPkId        = objSubCategory.AppSubCategoryID;
     objSubCategory = null;
     objCommon      = null;
     return(true);
 }
예제 #2
0
    protected void dgvGridView_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
    {
        if (!string.IsNullOrEmpty(e.CommandArgument.ToString()))
        {
            objCommon = new clsCommon();

            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("tblSubCategory", tblSubCategory.ColumnNames.AppSubCategoryID, tblSubCategory.ColumnNames.AppDisplayOrder, (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[0], (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[1], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[0], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[1]);
                    LoadDataGrid(false, false);
                    objCommon = null;
                }
            }
            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("tblSubCategory", tblSubCategory.ColumnNames.AppSubCategoryID, tblSubCategory.ColumnNames.AppDisplayOrder, (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[0], (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[1], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[0], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[1]);
                    LoadDataGrid(false, false);
                    objCommon = null;
                }
            }
            else if (e.CommandName == "IsActive")
            {
                objSubCategory = new tblSubCategory();
                if (objSubCategory.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())))
                {
                    if (objSubCategory.AppIsActive == true)
                    {
                        objSubCategory.AppIsActive = false;
                    }
                    else if (objSubCategory.AppIsActive == false)
                    {
                        objSubCategory.AppIsActive = true;
                    }
                    objSubCategory.Save();
                    LoadDataGrid(false, false, "", "");
                }
                objSubCategory = null;
            }
        }
    }