Esempio n. 1
0
    protected void OnFunctionFamDeleteClicked(object sender, EventArgs e)
    {
        LinkButton lnkItem = (LinkButton)sender;
        string functionFamID = lnkItem.CommandArgument;

        ParamFunctionFam deleteItem = new ParamFunctionFam(functionFamID);
        ParamFunctionFamRepository repo = new ParamFunctionFamRepository();
        repo.Delete(deleteItem);

        BindGridData();
        gridFunctionFam.DataBind();
    }
    protected void OnBtnSaveClicked(object sender, EventArgs e)
    {
        ParamFunctionFamRepository repo = new ParamFunctionFamRepository();

        ParamFunctionFam saveItem = new ParamFunctionFam();
        saveItem.FonctionFamID = txtFunctionFamID.Text;
        saveItem.Genre = txtGenre.Text;

        if (Request.QueryString["FunctionFamID"] == null)
        {
            //Insert new record
            ParamFunctionFam oldItem = repo.GetFunctionFamsByID(txtFunctionFamID.Text);

            if (oldItem == null)
                repo.InserNewFunctionFam(saveItem);
            else
            {
                string message = ResourceManager.GetString("itemAlreadyExist");
                string script1 = "<script type=\"text/javascript\">";
                script1 += " alert(\"" + message + "\");";
                script1 += " </script>";

                if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
                    ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script1);
            }
        }
        else
        {

            if (Request.QueryString["FunctionFamID"] == txtFunctionFamID.Text)
            {
                repo.Update(saveItem);
            }
            else
            {
                ParamFunctionFam oldItem = repo.GetFunctionFamsByID(Request.QueryString["FunctionFamID"]);
                if (oldItem.NumberIDUsed <= 0)
                {
                    repo.Delete(oldItem);
                    repo.InserNewFunctionFam(saveItem);
                }
                else
                {
                    string message = ResourceManager.GetString("messageFunctionFamBeingUsed");
                    string script1 = "<script type=\"text/javascript\">";
                    script1 += " alert(\"" + message + "\");";
                    script1 += " </script>";

                    if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
                        ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script1);
                }
            }

        }

        string script = "<script type=\"text/javascript\">";
        script += " OnBtnSaveClientClicked();";
        script += " </script>";

        if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
            ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script);
    }