private void AddValuesToTables()
 {
     try
     {
         _objTwoColumnTables                   = new TwoColumnTables();
         _objTwoColumnTables.TableName         = txtTableName.Text == string.Empty ? null : txtTableName.Text;
         _objTwoColumnTables.EntryMode         = txtEntryMode.Text == string.Empty ? null : txtEntryMode.Text;
         _objTwoColumnTables.RelatedTo         = txtRelatedTo.Text == string.Empty ? null : txtRelatedTo.Text;
         _objTwoColumnTables.RelatedUserRoleID = ddlRelatedUserRoleID.SelectedValue == "-1" ? 0 : Convert.ToInt32(ddlRelatedUserRoleID.SelectedValue);
         _objTwoColumnTables.EntrySystem       = ddlEntrySystem.SelectedValue == "-1" ? null : ddlEntrySystem.SelectedValue;
         _objTwoColumnTablesController         = new TwoColumnTablesController();
         if (btnSave.Text == "Save")
         {
             _objTwoColumnTablesController.Save(_connectionString, _objTwoColumnTables);
         }
         else
         {
             _objTwoColumnTables.TableID = Convert.ToInt32(Session["selectedIndex"].ToString());
             _objTwoColumnTablesController.Update(_connectionString, _objTwoColumnTables);
         }
     }
     catch (Exception msgException)
     {
         throw msgException;
     }
 }
Пример #2
0
 private void ShowsysTwoColumnTables()
 {
     try
     {
         _objTwoColumnTables = new TwoColumnTables();
         _objTwoColumnTables.RelatedUserRoleID = Convert.ToInt32(Session["relatedUserRoleID"].ToString());
         _objTwoColumnTables.EntrySystem       = "A";
         EmployeeSetup objEmployeeSetup = new EmployeeSetup();
         objEmployeeSetup.CompanyID    = LoginUserInformation.CompanyID;
         objEmployeeSetup.EmployeeID   = LoginUserInformation.EmployeeCode;
         _objTwoColumnTablesController = new TwoColumnTablesController();
         DataTable dtTablesName = _objTwoColumnTablesController.GetRecord(_connectionString, _objTwoColumnTables, objEmployeeSetup);
         grdTableName.DataSource = null;
         grdTableName.DataBind();
         if (dtTablesName.Rows.Count > 0)
         {
             grdTableName.DataSource = dtTablesName;
             grdTableName.DataBind();
         }
     }
     catch (Exception msgException)
     {
         throw msgException;
     }
 }
 private void ShowRecord()
 {
     try
     {
         _objTwoColumnTablesController = new TwoColumnTablesController();
         DataTable dtRecord = _objTwoColumnTablesController.GetRecord(_connectionString);
         grdTwoColumnTables.DataSource = null;
         grdTwoColumnTables.DataBind();
         if (dtRecord.Rows.Count > 0)
         {
             grdTwoColumnTables.DataSource = dtRecord;
             grdTwoColumnTables.DataBind();
         }
     }
     catch (Exception msgException)
     {
         throw msgException;
     }
 }
        protected void grdTwoColumnTables_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int    selectedIndex = Convert.ToInt32(e.CommandArgument.ToString());
            string lblTableID    = ((Label)grdTwoColumnTables.Rows[selectedIndex].FindControl("lblTableID")).Text;

            if (e.CommandName.Equals("Select"))
            {
                try
                {
                    string lblTableName         = ((Label)grdTwoColumnTables.Rows[selectedIndex].FindControl("lblTableName")).Text;
                    string lblEntryMode         = ((Label)grdTwoColumnTables.Rows[selectedIndex].FindControl("lblEntryMode")).Text;
                    string lblRelatedTo         = ((Label)grdTwoColumnTables.Rows[selectedIndex].FindControl("lblRelatedTo")).Text;
                    string lblEntrySystem       = ((Label)grdTwoColumnTables.Rows[selectedIndex].FindControl("lblEntrySystem")).Text;
                    string lblRelatedUserRoleID = ((Label)grdTwoColumnTables.Rows[selectedIndex].FindControl("lblRelatedUserRoleID")).Text;
                    txtTableName.Text = lblTableName;
                    txtEntryMode.Text = lblEntryMode;
                    txtRelatedTo.Text = lblRelatedTo;
                    ddlRelatedUserRoleID.SelectedValue = lblRelatedUserRoleID;
                    ddlEntrySystem.SelectedValue       = lblEntrySystem;
                    btnSave.Text             = "Update";
                    Session["selectedIndex"] = lblTableID;
                }
                catch (Exception msgException)
                {
                    clsTopMostMessageBox.Show(msgException.Message);
                }
            }
            else if (e.CommandName.Equals("Delete"))
            {
                try
                {
                    _objTwoColumnTables           = new TwoColumnTables();
                    _objTwoColumnTables.TableID   = Convert.ToInt32(lblTableID);
                    _objTwoColumnTablesController = new TwoColumnTablesController();
                    _objTwoColumnTablesController.Delete(_connectionString, _objTwoColumnTables);
                    ShowRecord();
                }
                catch (Exception msgException)
                {
                    clsTopMostMessageBox.Show(msgException.Message);
                }
            }
        }