Example #1
0
    protected void OnLanguageDeleteClicked(object sender, EventArgs e)
    {
        LinkButton lnkItem = (LinkButton)sender;
        string languageID = lnkItem.CommandArgument;

        ParamLangue deleteItem = new ParamLangue(languageID);
        ParamLangueRepository repo = new ParamLangueRepository();
        repo.Delete(deleteItem);

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

        ParamLangue saveItem = new ParamLangue();
        saveItem.LangueID = txtLanguageID.Text;
        saveItem.Label = txtLabel.Text;

        if (Request.QueryString["LanguageID"] == null)
        {
            //Insert new record
            ParamLangue oldItem = repo.GetLanguageByID(txtLanguageID.Text);

            if (oldItem == null)
                repo.InserNewLanguage(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["LanguageID"] == txtLanguageID.Text)
            {
                repo.Update(saveItem);
            }
            else
            {
                ParamLangue oldItem = repo.GetLanguageByID(Request.QueryString["LanguageID"]);
                if (oldItem.NumberIDUsed <= 0)
                {
                    repo.Delete(oldItem);
                    repo.InserNewLanguage(saveItem);
                }
                else
                {
                    string message = ResourceManager.GetString("messageLanguageBeingUsed");
                    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);
    }