예제 #1
0
        protected void chkBranch_OnCheckedChanged(object sender, EventArgs e)
        {
            try
            {
                int         selRowIndex = ((GridViewRow)(((CheckBox)sender).Parent.Parent)).RowIndex;
                CheckBox    cb          = (CheckBox)GridBranch.Rows[selRowIndex].FindControl("chkBranch");
                HiddenField BranchCode  = (HiddenField)GridBranch.Rows[selRowIndex].FindControl("HfBranch_Code");

                if (cb.Checked)
                {
                    //ADD

                    string str = BRANCH_MASLogicLayer.InsertUSER_BRANCHDetail(BranchCode.Value, DdlUser.SelectedValue.ToString(), DdlCompany.SelectedValue.ToString());
                    if (str.Contains("successfully"))
                    {
                        lblmsg.Text      = "BRANCH ADD SUCCESSFULLY.";
                        lblmsg.ForeColor = Color.Green;
                    }
                    else if (str.Contains("Already") || str.Contains("PRIMARY KEY"))
                    {
                        lblmsg.Text      = "BRANCH ALREADY EXIST.";
                        lblmsg.ForeColor = Color.Red;
                    }
                    else
                    {
                        lblmsg.Text      = "ERROR : BRANCH NOT ASSIGNED";
                        lblmsg.ForeColor = Color.Red;
                    }
                }
                else
                {
                    //REMOVE


                    string str = BRANCH_MASLogicLayer.DELETEUSER_BRANCHDetail(BranchCode.Value, DdlUser.SelectedValue.ToString(), DdlCompany.SelectedValue.ToString());
                    if (str.Contains("successfully"))
                    {
                        lblmsg.Text      = "BRANCH REMOVE SUCCESSFULLY.";
                        lblmsg.ForeColor = Color.Green;
                    }
                    else if (str.Contains("Already") || str.Contains("PRIMARY KEY"))
                    {
                        lblmsg.Text      = "BRANCH ALREADY EXIST.";
                        lblmsg.ForeColor = Color.Red;
                    }
                    else
                    {
                        lblmsg.Text      = "ERROR : BRANCH NOT REMOVED";
                        lblmsg.ForeColor = Color.Red;
                    }
                }

                FillGridBranch();
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
        protected void GridBranch_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "Adda")
                {
                    string str = BRANCH_MASLogicLayer.InsertUSER_BRANCHDetail(e.CommandArgument.ToString(), DdlUser.SelectedValue.ToString(), DdlCompany.SelectedValue.ToString());
                    if (str.Contains("successfully"))
                    {
                        lblmsg.Text      = "BRANCH ADD SUCCESSFULLY.";
                        lblmsg.ForeColor = Color.Green;
                    }
                    else if (str.Contains("Already") || str.Contains("PRIMARY KEY"))
                    {
                        lblmsg.Text      = "BRANCH ALREADY EXIST.";
                        lblmsg.ForeColor = Color.Red;
                    }
                    else
                    {
                        lblmsg.Text      = "ERROR : BRANCH NOT ASSIGNED";
                        lblmsg.ForeColor = Color.Red;
                    }
                }
                else if (e.CommandName == "Removea")
                {
                    string str = BRANCH_MASLogicLayer.DELETEUSER_BRANCHDetail(e.CommandArgument.ToString(), DdlUser.SelectedValue.ToString(), DdlCompany.SelectedValue.ToString());
                    if (str.Contains("successfully"))
                    {
                        lblmsg.Text      = "BRANCH REMOVE SUCCESSFULLY.";
                        lblmsg.ForeColor = Color.Green;
                    }
                    else if (str.Contains("Already") || str.Contains("PRIMARY KEY"))
                    {
                        lblmsg.Text      = "BRANCH ALREADY EXIST.";
                        lblmsg.ForeColor = Color.Red;
                    }
                    else
                    {
                        lblmsg.Text      = "ERROR : BRANCH NOT REMOVED";
                        lblmsg.ForeColor = Color.Red;
                    }
                }

                FillGridBranch();
            }
            catch (Exception)
            {
                throw;
            }
        }