Example #1
0
        protected void SubmitCode(object sender, EventArgs e)
        {
            if (Session["codedesc"] != null)
            {
                //If session "codedesc" is not equals null, means edit button event was triggered from Maintainence_Management.aspx table
                int check;

                //Trigger the EditCode Method in DatabaseDAO and store textbox values into parameters
                check = dao.EditCode(LkUpCode.Value.ToUpper(), CodeDesc.Value.ToUpper(), Session["codedesc"].ToString(), Session["type"].ToString());
                if (check == 1)
                {
                    //If no error, display success message
                    //Add parameter to change message of AlertBox
                    ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "displaySuccess('Successfully Edited New Code: " + LkUpCode.Value.ToUpper() + "');", true);
                }
                else
                {
                    //If error, display failure message
                    ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "displayFailure();", true);
                }
            }
            else
            {
                //If session "codedesc" is equals to null, means add button event was triggered from Maintainence_Management.aspx
                int check;

                //Trigger the AddCode Method in DatabaseDAO and sotre textbox values into parameters
                check = dao.AddCode(Session["type"].ToString(), LkUpCode.Value.ToUpper(), CodeDesc.Value.ToUpper());
                if (check == 1)
                {
                    //If no error, display success message
                    //Add parameter to change message of AlertBox
                    ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "displaySuccess('Successfully Created New Code: " + LkUpCode.Value.ToUpper() + "');", true);
                }
                else
                {
                    //If error, display failure message
                    ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "displayFailure();", true);
                }
            }
        }