Ejemplo n.º 1
0
    protected void OnKnowledgeFamDeleteClicked(object sender, EventArgs e)
    {
        LinkButton lnkItem = (LinkButton)sender;
        string knowledgeFamID = lnkItem.CommandArgument;

        ParamKnowledgeFam deleteItem = new ParamKnowledgeFam(knowledgeFamID);
        ParamKnowledgeFamRepository repo = new ParamKnowledgeFamRepository();
        repo.Delete(deleteItem);

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

        ParamKnowledgeFam saveItem = new ParamKnowledgeFam();
        saveItem.ConFamilleID = txtKnowledgeFamID.Text;
        saveItem.Genre = txtGenre.Text;

        if (Request.QueryString["KnowledgeFamID"] == null)
        {
            //Insert new record
            ParamKnowledgeFam oldItem = repo.GetKnowledgeFamByID(txtKnowledgeFamID.Text);

            if (oldItem == null)
                repo.InserNewKnowledgeFam(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["KnowledgeFamID"] == txtKnowledgeFamID.Text)
            {
                repo.Update(saveItem);
            }
            else
            {
                ParamKnowledgeFam oldItem = repo.GetKnowledgeFamByID(Request.QueryString["KnowledgeFamID"]);
                if (oldItem.NumberIDUsed <= 0)
                {
                    repo.Delete(oldItem);
                    repo.InserNewKnowledgeFam(saveItem);
                }
                else
                {
                    string message = ResourceManager.GetString("messageKnowledgeFamBeingUsed");
                    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);
    }