public MainOfficeType GetDetails(int mainOfficeTypeID)
        {
            MainOfficeType mainOfficeType = new MainOfficeType();

            SqlParameter[] parametersMainOfficeType = new SqlParameter[]
            {
                new SqlParameter("@MainOfficeTypeID", mainOfficeTypeID)
            };
            using (DataTable table = SqlDBHelper.ExecuteParamerizedSelectCommand("MainOfficeType_GetDetails", CommandType.StoredProcedure, parametersMainOfficeType))
            {
                if (table.Rows.Count == 1)
                {
                    DataRow row = table.Rows[0];

                    mainOfficeType.MainOfficeTypeID           = (row["MainOfficeTypeID"] != DBNull.Value) ? Convert.ToInt32(row["MainOfficeTypeID"]) : 0;
                    mainOfficeType.ContractualEmployeesNumber = (row["ContractualEmployeesNumber"] != DBNull.Value) ? Convert.ToInt64(row["ContractualEmployeesNumber"]) : 0;
                    mainOfficeType.Title          = row["Title"].ToString();
                    mainOfficeType.TotalScore     = (row["TotalScore"] != DBNull.Value) ? Convert.ToDecimal(row["TotalScore"]) : 0;
                    mainOfficeType.TotalScoreCat1 = (row["TotalScoreCat1"] != DBNull.Value) ? Convert.ToDecimal(row["TotalScoreCat1"]) : 0;
                    mainOfficeType.TotalScoreCat2 = (row["TotalScoreCat2"] != DBNull.Value) ? Convert.ToDecimal(row["TotalScoreCat2"]) : 0;
                }
            }

            return(mainOfficeType);
        }
        public List <MainOfficeType> SearchLike(MainOfficeType mainOfficeType)
        {
            List <MainOfficeType> listMainOfficeType = new List <MainOfficeType>();


            SqlParameter[] parametersMainOfficeType = new SqlParameter[]
            {
                new SqlParameter("@MainOfficeTypeID", mainOfficeType.MainOfficeTypeID),
                new SqlParameter("@ContractualEmployeesNumber", mainOfficeType.ContractualEmployeesNumber),
                new SqlParameter("@Title", mainOfficeType.Title),
                new SqlParameter("@TotalScore", mainOfficeType.TotalScore),
                new SqlParameter("@TotalScoreCat1", mainOfficeType.TotalScoreCat1),
                new SqlParameter("@TotalScoreCat2", mainOfficeType.TotalScoreCat2),
            };
            using (DataTable table = SqlDBHelper.ExecuteParamerizedSelectCommand("MainOfficeType_SearchLike", CommandType.StoredProcedure, parametersMainOfficeType))
            {
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        MainOfficeType tmpMainOfficeType = new MainOfficeType();
                        tmpMainOfficeType.MainOfficeTypeID           = (row["MainOfficeTypeID"] != DBNull.Value) ? Convert.ToInt32(row["MainOfficeTypeID"]) : 0;
                        tmpMainOfficeType.ContractualEmployeesNumber = (row["ContractualEmployeesNumber"] != DBNull.Value) ? Convert.ToInt64(row["ContractualEmployeesNumber"]) : 0;
                        tmpMainOfficeType.Title          = row["Title"].ToString();
                        tmpMainOfficeType.TotalScore     = (row["TotalScore"] != DBNull.Value) ? Convert.ToDecimal(row["TotalScore"]) : 0;
                        tmpMainOfficeType.TotalScoreCat1 = (row["TotalScoreCat1"] != DBNull.Value) ? Convert.ToDecimal(row["TotalScoreCat1"]) : 0;
                        tmpMainOfficeType.TotalScoreCat2 = (row["TotalScoreCat2"] != DBNull.Value) ? Convert.ToDecimal(row["TotalScoreCat2"]) : 0;

                        listMainOfficeType.Add(tmpMainOfficeType);
                    }
                }
            }

            return(listMainOfficeType);
        }
        public List <MainOfficeType> GetListAll()
        {
            List <MainOfficeType> listMainOfficeType = null;

            using (DataTable table = SqlDBHelper.ExecuteSelectCommand("MainOfficeType_GetListAll", CommandType.StoredProcedure))
            {
                if (table.Rows.Count > 0)
                {
                    listMainOfficeType = new List <MainOfficeType>();

                    foreach (DataRow row in table.Rows)
                    {
                        MainOfficeType mainOfficeType = new MainOfficeType();
                        mainOfficeType.MainOfficeTypeID           = (row["MainOfficeTypeID"] != DBNull.Value) ? Convert.ToInt32(row["MainOfficeTypeID"]) : 0;
                        mainOfficeType.ContractualEmployeesNumber = (row["ContractualEmployeesNumber"] != DBNull.Value) ? Convert.ToInt64(row["ContractualEmployeesNumber"]) : 0;
                        mainOfficeType.Title          = row["Title"].ToString();
                        mainOfficeType.TotalScore     = (row["TotalScore"] != DBNull.Value) ? Convert.ToDecimal(row["TotalScore"]) : 0;
                        mainOfficeType.TotalScoreCat1 = (row["TotalScoreCat1"] != DBNull.Value) ? Convert.ToDecimal(row["TotalScoreCat1"]) : 0;
                        mainOfficeType.TotalScoreCat2 = (row["TotalScoreCat2"] != DBNull.Value) ? Convert.ToDecimal(row["TotalScoreCat2"]) : 0;
                        listMainOfficeType.Add(mainOfficeType);
                    }
                }
            }

            return(listMainOfficeType);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        string mainOfficeTypeID = Request.QueryString["mainOfficeTypeID"] as string;

        if (mainOfficeTypeID == null)
        {
            Response.Redirect("Z_MainOfficeTypeDefault.aspx");
        }

        try
        {
            mainOfficeTypeMainOfficeTypeID = Convert.ToInt32(mainOfficeTypeID.Trim());
            mainOfficeTypeHandler          = new MainOfficeTypeHandler();

            MainOfficeType mainOfficeType = mainOfficeTypeHandler.GetDetails(mainOfficeTypeMainOfficeTypeID);

            lblMainOfficeTypeID.Text           = mainOfficeType.MainOfficeTypeID.ToString();
            lblContractualEmployeesNumber.Text = mainOfficeType.ContractualEmployeesNumber.ToString();
            lblTitle.Text          = mainOfficeType.Title.ToString();
            lblTotalScore.Text     = mainOfficeType.TotalScore.ToString();
            lblTotalScoreCat1.Text = mainOfficeType.TotalScoreCat1.ToString();
            lblTotalScoreCat2.Text = mainOfficeType.TotalScoreCat2.ToString();
        }
        catch (Exception)
        {
            Response.Redirect("Z_MainOfficeTypeDefault.aspx");
        }
    }
Exemplo n.º 5
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Label   lblMainOfficeTypeID           = GridView1.Rows[e.RowIndex].FindControl("lblMainOfficeTypeID") as Label;
        Label   lblContractualEmployeesNumber = GridView1.Rows[e.RowIndex].FindControl("lblContractualEmployeesNumber") as Label;
        TextBox txtTitle          = GridView1.Rows[e.RowIndex].FindControl("txtTitle") as TextBox;
        TextBox txtTotalScore     = GridView1.Rows[e.RowIndex].FindControl("txtTotalScore") as TextBox;
        TextBox txtTotalScoreCat1 = GridView1.Rows[e.RowIndex].FindControl("txtTotalScoreCat1") as TextBox;
        TextBox txtTotalScoreCat2 = GridView1.Rows[e.RowIndex].FindControl("txtTotalScoreCat2") as TextBox;


        if (lblMainOfficeTypeID != null && lblContractualEmployeesNumber != null && txtTitle != null && txtTotalScore != null && txtTotalScoreCat1 != null && txtTotalScoreCat2 != null)
        {
            MainOfficeType mainOfficeType = new MainOfficeType();

            mainOfficeType.MainOfficeTypeID           = Convert.ToInt32(lblMainOfficeTypeID.Text.Trim());
            mainOfficeType.ContractualEmployeesNumber = Convert.ToInt64(lblContractualEmployeesNumber.Text.Trim());
            mainOfficeType.Title = txtTitle.Text;

            //Let us now update the database
            if (mainOfficeTypeHandler.Update(mainOfficeType) == true)
            {
                lblResult.Text = "Record Updated Successfully";
            }
            else
            {
                lblResult.Text = "Failed to Update record";
            }

            //end the editing and bind with updated records.
            GridView1.EditIndex = -1;
            BindData();
        }
    }
 public bool Exists(MainOfficeType mainOfficeType)
 {
     SqlParameter[] parametersMainOfficeType = new SqlParameter[]
     {
         new SqlParameter("@MainOfficeTypeID", mainOfficeType.MainOfficeTypeID)
     };
     return(SqlDBHelper.ExecuteScalar("MainOfficeType_Exists", CommandType.StoredProcedure, parametersMainOfficeType) > 0);
 }
 public bool Update(MainOfficeType mainOfficeType)
 {
     SqlParameter[] parametersMainOfficeType = new SqlParameter[]
     {
         new SqlParameter("@MainOfficeTypeID", mainOfficeType.MainOfficeTypeID),
         new SqlParameter("@Title", mainOfficeType.Title),
         new SqlParameter("@TotalScore", (mainOfficeType.TotalScore != null) ? mainOfficeType.TotalScore : (object)DBNull.Value),
         new SqlParameter("@TotalScoreCat1", (mainOfficeType.TotalScoreCat1 != null) ? mainOfficeType.TotalScoreCat1 : (object)DBNull.Value),
         new SqlParameter("@TotalScoreCat2", (mainOfficeType.TotalScoreCat2 != null) ? mainOfficeType.TotalScoreCat2 : (object)DBNull.Value)
     };
     return(SqlDBHelper.ExecuteNonQuery("MainOfficeType_Update", CommandType.StoredProcedure, parametersMainOfficeType));
 }
 public Int64 Insert(MainOfficeType mainOfficeType)
 {
     SqlParameter[] parametersMainOfficeType = new SqlParameter[]
     {
         new SqlParameter("@Title", mainOfficeType.Title),
         new SqlParameter("@TotalScore", (mainOfficeType.TotalScore != null) ? mainOfficeType.TotalScore : (object)DBNull.Value),
         new SqlParameter("@TotalScoreCat1", (mainOfficeType.TotalScoreCat1 != null) ? mainOfficeType.TotalScoreCat1 : (object)DBNull.Value),
         new SqlParameter("@TotalScoreCat2", (mainOfficeType.TotalScoreCat2 != null) ? mainOfficeType.TotalScoreCat2 : (object)DBNull.Value)
     };
     mainOfficeType.MainOfficeTypeID = Convert.ToInt32(SqlDBHelper.ExecuteScalar("MainOfficeType_Insert", CommandType.StoredProcedure, parametersMainOfficeType));
     return(mainOfficeType.MainOfficeTypeID);
 }
    protected void btnYES_Click(object sender, EventArgs e)
    {
        MainOfficeType mainOfficeType = new MainOfficeType();

        mainOfficeType.Title = txtTitle.Text;

        MainOfficeTypeHandler mainOfficeTypeHandler = new MainOfficeTypeHandler();

        if (mainOfficeTypeHandler.Insert(mainOfficeType) > 0)
        {
            Response.Redirect("Z_MainOfficeTypeDefault.aspx");
        }
    }