Esempio n. 1
0
        protected void btnGroup_Click(object sender, EventArgs e)
        {
            try
            {
                if (ddlClient.SelectedValue != "0" && txtGroupName.Text != "" && txtComments.Text != "")
                {
                    GetGroupModel model = new GetGroupModel();
                    model.ClientID = Convert.ToInt32(ddlClient.SelectedValue);
                    model.Name     = txtGroupName.Text;
                    model.Comment  = txtComments.Text;

                    if (btnGroup.Text == "Save")
                    {
                        model.GroupID = 0;
                        bool exist = obj.groupExist(model.Name);
                        if (exist == false)
                        {
                            bool status = obj.postGroup(model);
                            if (status == true)
                            {
                                alert = AlertsClass.SuccessAdd;
                            }
                            else
                            {
                                alert = AlertsClass.ErrorWentWrong;
                            }
                        }
                        else
                        {
                            alert = AlertsClass.ErrorExist("Branch");
                        }
                    }
                    if (btnGroup.Text == "Update")
                    {
                        model.GroupID = Convert.ToInt32(Session["GroupId"]);
                        bool status = obj.postGroup(model);
                        if (status == true)
                        {
                            alert = AlertsClass.SuccessUpdate;
                        }
                        else
                        {
                            alert = AlertsClass.ErrorWentWrong;
                        }
                    }
                }
                else
                {
                    alert = AlertsClass.ErrorRequired;
                }
                clearControls();
                gridBind();
                allowStaticMethods("ALerts('" + alert + "'); ApplyDatatable('.gvdGroupClass'); staticMethod('Disable');");
            }
            catch (Exception)
            { BindingClass.ExceptionAlertScriptManager(this.Page, this.GetType()); }
        }