예제 #1
0
        protected void GridViewRegion_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                switch (e.CommandName.ToLower())
                {
                case "removeemployeelocation":
                {
                    EmployeeRegion.DeleteEmployeeRegionByEmployeeRegionId(Convert.ToInt32(e.CommandArgument));
                    BindEmployeeRegionList();

                    break;
                }
                }
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                LabelError.Text = "";
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                }
                PanelError.Visible = true;
            }
        }
예제 #2
0
        protected void ButtonAddLocation_Click(object sender, EventArgs e)
        {
            //if (Page.IsValid)
            //{
            LabelError.Text = "";
            bool hasError = false;

            PanelError.Visible = false;

            //if (Convert.ToInt32(DropDownListLocation.SelectedValue) == 0)
            //{
            //    LabelError.Text += "Location is required.\n";
            //    PanelError.Visible = true;
            //    hasError = true;
            //}

            if (hasError == false)
            {
                try
                {
                    int companyId = Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).CompanyId;

                    EmployeeLocation.InsertEmployeeLocation(this.employeeId, Convert.ToInt32(DropDownListLocation.SelectedValue), this.Master.LoggedOnAccount, companyId);

                    if (DropDownListLocation.SelectedItem.Text != "CENTRAL")
                    {
                        EmployeeRegion.InsertEmployeeRegion(this.employeeId, Convert.ToInt32(DropDownListLocation.SelectedValue), this.Master.LoggedOnAccount, companyId);
                        //RepStore.InsertRepresentativeStoreByLocationId(this.employeeId, Convert.ToInt32(DropDownListLocation.SelectedValue), this.Master.LoggedOnAccount);

                        BindEmployeeRegionList();
                    }

                    BindEmployeeLocationList();
                }
                catch (System.Data.SqlClient.SqlException sqlEx)
                {
                    LabelError.Text = "";
                    for (int i = 0; i < sqlEx.Errors.Count; i++)
                    {
                        LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                    }
                    PanelError.Visible = true;
                }
            }
            //}
        }