public void ListAndCountOK()
        {
            //create an instance of the class we want to create
            clsEmployeeCollection AllEmployee = new clsEmployeeCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <ClsEmployee> TestList = new List <ClsEmployee>();
            //add an item to the list
            //create the item of test data
            ClsEmployee TestEmployee = new ClsEmployee();

            //set its properties
            TestEmployee.Emp_ID     = 113;
            TestEmployee.Emp_Name   = "Jake Wills";
            TestEmployee.Job_Name   = "Supporter";
            TestEmployee.Manager_ID = 2;
            TestEmployee.Hire_Date  = DateTime.Now.Date;
            TestEmployee.Salary     = 22000;
            TestEmployee.Dep_ID     = 3;
            TestEmployee.Active     = true;
            //add the item to the test list
            TestList.Add(TestEmployee);
            //assign the data to the property
            AllEmployee.EmployeeList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllEmployee.Count, TestList.Count);
        }
        public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsEmployeeCollection AllEmployee = new clsEmployeeCollection();
            //create the item of test data
            ClsEmployee TestEmployee = new ClsEmployee();
            //var to store the primary key
            Int32 PrimaryKey = 119;

            //set its properties
            TestEmployee.Emp_Name   = "Jake Wills";
            TestEmployee.Job_Name   = "Supporter";
            TestEmployee.Manager_ID = 2;
            TestEmployee.Hire_Date  = DateTime.Now.Date;
            TestEmployee.Salary     = 22000;
            TestEmployee.Dep_ID     = 3;
            TestEmployee.Active     = true;
            //set ThisEmployee to the test data
            AllEmployee.ThisEmployee = TestEmployee;
            //add the record
            AllEmployee.Add();
            //set the primary key of the test data
            //find the record
            AllEmployee.ThisEmployee.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllEmployee.ThisEmployee, TestEmployee);
        }
Beispiel #3
0
    protected void btnFind_Click(object sender, EventArgs e)
    {
        ClsEmployee AnEmployee = new ClsEmployee();
        Int32       emp_ID;
        Boolean     Found = false;

        if (txtemp_ID.Text != "")
        {
            emp_ID = Convert.ToInt32(txtemp_ID.Text);
            Found  = AnEmployee.Find(emp_ID);
        }
        else
        {
            lblError.Text = "Please enter a employee ID";
        }

        if (Found == true)
        {
            lblError.Text      = "";
            txtemp_Name.Text   = AnEmployee.Emp_Name;
            txtjob_Name.Text   = AnEmployee.Job_Name;
            txtmanager_ID.Text = AnEmployee.Manager_ID.ToString();
            txthire_Date.Text  = AnEmployee.Hire_Date.ToString();
            txtsalary.Text     = AnEmployee.Salary.ToString();
            txtdep_ID.Text     = AnEmployee.Dep_ID.ToString();
            chkActive.Checked  = AnEmployee.Active;
        }
    }
        public void DeleteMethodOK()
        {
            //create an instance of the class we want to create
            clsEmployeeCollection AllEmployees = new clsEmployeeCollection();
            //create the item of test data
            ClsEmployee TestEmployee = new ClsEmployee();
            //var to store the primary key
            Int32 PrimaryKey = 117;

            //set its properties
            TestEmployee.Emp_Name   = "Jake Wills";
            TestEmployee.Job_Name   = "Supporter";
            TestEmployee.Manager_ID = 2;
            TestEmployee.Hire_Date  = DateTime.Now.Date;
            TestEmployee.Salary     = 22000;
            TestEmployee.Dep_ID     = 3;
            TestEmployee.Active     = true;
            //set ThisAddress to the test data
            AllEmployees.ThisEmployee = TestEmployee;
            //add the record
            PrimaryKey = AllEmployees.Add();
            //set the primary key of the test data
            TestEmployee.Emp_ID = PrimaryKey;
            //find the record
            AllEmployees.ThisEmployee.Find(PrimaryKey);
            //delete the record
            AllEmployees.Delete();
            //now find the record
            Boolean Found = AllEmployees.ThisEmployee.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
Beispiel #5
0
        public void InstanceOK()
        {
            //create an instance of the class
            ClsEmployee AnEmployee = new ClsEmployee();

            //test to see if it exists
            Assert.IsNotNull(AnEmployee);
        }
Beispiel #6
0
        public DataTable Employee_details(ClsEmployee ObjClsEmployee)
        {
            DataTable objDataTable = new DataTable();

            try
            {
                DataSet objDataset;

                objDBLibrary = new DBCon();

                objDBLibrary._stringCommandText = "sp_employee_master";
                objDBLibrary._CommandType       = CommandType.StoredProcedure;

                objSqlParameter = new SqlParameter[9];

                objSqlParameter[0]       = new SqlParameter("@employee_id", SqlDbType.Int);
                objSqlParameter[0].Value = ObjClsEmployee.employee_id;

                objSqlParameter[1]       = new SqlParameter("@employee_name", SqlDbType.VarChar, 50);
                objSqlParameter[1].Value = ObjClsEmployee.employee_name;

                objSqlParameter[2]       = new SqlParameter("@father_name", SqlDbType.VarChar, 50);
                objSqlParameter[2].Value = ObjClsEmployee.father_name;

                objSqlParameter[3]       = new SqlParameter("@mother_name", SqlDbType.VarChar, 50);
                objSqlParameter[3].Value = ObjClsEmployee.mother_name;

                objSqlParameter[4]       = new SqlParameter("@DOB", SqlDbType.Date);
                objSqlParameter[4].Value = ObjClsEmployee.DOB;

                objSqlParameter[5]       = new SqlParameter("@gender", SqlDbType.Int);
                objSqlParameter[5].Value = ObjClsEmployee.gender;

                objSqlParameter[6]       = new SqlParameter("@marital_status", SqlDbType.Int);
                objSqlParameter[6].Value = ObjClsEmployee.marital_status;

                objSqlParameter[7]       = new SqlParameter("@Address", SqlDbType.VarChar, 2000);
                objSqlParameter[7].Value = ObjClsEmployee.Address;

                objSqlParameter[8]       = new SqlParameter("@Dml_Indicator", SqlDbType.VarChar, 10);
                objSqlParameter[8].Value = ObjClsEmployee.Dml_Indicator;


                objDataset = objDBLibrary.GetDataAdapter(objSqlParameter);

                if (objDataset != null && objDataset.Tables[0].Rows.Count > 0)
                {
                    return(objDataset.Tables[0]);
                }
            }
            catch (Exception objException)
            {
                Exception objErr = objException.GetBaseException();
            }

            return(objDataTable);
        }
 async Task InsertEmployee(ClsEmployee employee)
 {
     try
     {
         await apiCore.PostEmployee(employee);
     }
     catch (Exception ex)
     {
         await dialogService.DisplayAlertAsync("There was an error", $"{ex.Message}", "Ok");
     }
 }
        protected override void Page_Load(object sender, EventArgs e)
        {
            if (!this.CheckIsLoaded())
            {
                base.Page_Load(sender, e);
                this.mObj = (ClsEmployee)this.pObj_Base;

                if (!this.IsPostBack)
                {
                    this.SetupPage();
                }
            }
        }
Beispiel #9
0
        public void ValidMethodOK()
        {
            //create an instance of the class
            ClsEmployee AnEmployee = new ClsEmployee();
            //string variable to store any error message
            String   Error     = "";
            DateTime hire_Date = DateTime.Now.Date;

            //invoke the method
            Error = AnEmployee.Valid(emp_Name, job_Name, manager_ID, hire_Date, salary, dep_ID, active);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
Beispiel #10
0
        public void FindMethodOK()
        {
            //creates an instance
            ClsEmployee AnEmployee = new ClsEmployee();
            //boolean variable to store the result
            Boolean Found = false;
            //test data
            int emp_ID = 38;

            //invoke the method
            Found = AnEmployee.Find(emp_ID);
            //test to see that the result is correct
            Assert.IsTrue(Found);
        }
Beispiel #11
0
        public void EmployeeNameMinLessOne()
        {
            //create an instance of the class we want to create
            ClsEmployee AnEmployee = new ClsEmployee();
            //string variable to store any error message
            String Error = ""; DateTime hire_Date = DateTime.Now.Date;
            //create some test data to pass to the method
            string emp_Name = ""; //this should trigger an error

            //invoke the method
            Error = AnEmployee.Valid(emp_Name, job_Name, manager_ID, hire_Date, salary, dep_ID, active);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Beispiel #12
0
        public void ManagerIDMaxLessOne()
        {
            //create an instance of the class we want to create
            ClsEmployee AnEmployee = new ClsEmployee();
            //string variable to store any error message
            String Error = ""; DateTime hire_Date = DateTime.Now.Date;
            //create some test data to pass to the method
            int manager_ID = 199; //this should be ok

            //invoke the method
            Error = AnEmployee.Valid(emp_Name, job_Name, Convert.ToString(manager_ID), hire_Date, salary, dep_ID, active);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
Beispiel #13
0
        public void SalaryExtremeMax()
        {
            //create an instance of the class we want to create
            ClsEmployee AnEmployee = new ClsEmployee();
            //string variable to store any error message
            String Error = ""; DateTime hire_Date = DateTime.Now.Date;
            //create some test data to pass to the method
            int salary = 4000000; //this should fail

            //invoke the method
            Error = AnEmployee.Valid(emp_Name, job_Name, manager_ID, hire_Date, Convert.ToString(salary), dep_ID, active);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
        public HttpResponseMessage Employee_details([FromBody] ClsEmployee ObjClsEmployee)
        {
            try
            {
                objBEmployee = new BEmployee();
                objDataTable = new DataTable();
                objDataTable = objBEmployee.Employee_details(ObjClsEmployee);

                return(response = Request.CreateResponse(HttpStatusCode.OK, objDataTable));
            }
            catch (Exception objException)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, objException.Message));
            }
        }
Beispiel #15
0
        private void Addtool_Click(object sender, EventArgs e)
        {
            int salary;

            if (!int.TryParse(Salarytext.Text, out salary))// ! 等於not
            {
                MessageBox.Show("薪水不想整數??");
            }
            ClsEmployee s = new ClsEmployee();

            s.Employees(EMPtext.Text, HiredateTime.Value, salary, (Jobitle)Titlecombo.SelectedIndex);
            list.Add(s);
            MessageBox.Show("加入成功");
            Reorganize();
            EMPtext.Text = ""; Salarytext.Text = "";
        }
Beispiel #16
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        ClsEmployee AnEmployee = new ClsEmployee();


        string emp_Name   = txtemp_Name.Text;
        string job_Name   = txtjob_Name.Text;
        string dep_ID     = txtdep_ID.Text;
        string hire_Date  = txthire_Date.Text;
        string manager_ID = txtmanager_ID.Text;
        string salary     = txtsalary.Text;
        string check      = chkActive.Text;
        string Error      = "";

        Error = AnEmployee.Valid(emp_Name, job_Name, manager_ID, Convert.ToDateTime(hire_Date), salary, dep_ID, chkActive.Checked);
        if (Error == "")
        {
            AnEmployee.Emp_ID     = emp_ID;
            AnEmployee.Emp_Name   = emp_Name;
            AnEmployee.Job_Name   = job_Name;
            AnEmployee.Manager_ID = Convert.ToInt32(manager_ID);
            AnEmployee.Hire_Date  = Convert.ToDateTime(hire_Date);
            AnEmployee.Salary     = Convert.ToInt32(salary);
            AnEmployee.Dep_ID     = Convert.ToInt32(dep_ID);
            AnEmployee.Active     = chkActive.Checked;

            clsEmployeeCollection EmployeeList = new clsEmployeeCollection();

            if (Convert.ToInt32(emp_ID) == -1)
            {
                EmployeeList.ThisEmployee = AnEmployee;
                EmployeeList.Add();
            }
            else
            {
                EmployeeList.ThisEmployee.Find(Convert.ToInt32(emp_ID));
                EmployeeList.ThisEmployee = AnEmployee;
                EmployeeList.Update();
            }
            Response.Redirect("DefaultEmployee.aspx");
        }
        else
        {
            lblError.Text = Error;
        }
    }
Beispiel #17
0
        //public ActionResult About()
        //{
        //    ViewBag.Message = "Your application description page.";

        //    return View();
        //}

        //public ActionResult Contact()
        //{
        //    ViewBag.Message = "Your contact page.";

        //    return View();
        //}

        public JsonResult Employee_details(ClsEmployee objClsEmployee)
        {
            try
            {
                objresponseMessage = objHttpClient.PostAsJsonAsync(CommonFunction.objWebApiUrl + "Employee/Employee_details", objClsEmployee).Result;
                var DoctorSchedule = objresponseMessage.Content.ReadAsStringAsync().Result;
                if (objresponseMessage.IsSuccessStatusCode)
                {
                    return(Json(DoctorSchedule, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
            }

            return(Json(new EmptyResult(), JsonRequestBehavior.AllowGet));
        }
Beispiel #18
0
        public void Active_PropertyOK()

        {
            //an instance of the class

            ClsEmployee AnEmployee = new ClsEmployee();

            //test data

            bool TestData = true;

            //assigning data

            AnEmployee.Active = TestData;

            //test

            Assert.AreEqual(AnEmployee.Active, TestData);
        }
Beispiel #19
0
        public void Salary_PropertyOK()

        {
            //an instance of the class

            ClsEmployee AnEmployee = new ClsEmployee();

            //test data

            int TestData = 12000;

            //assigning data

            AnEmployee.Salary = TestData;

            //test

            Assert.AreEqual(AnEmployee.Salary, TestData);
        }
Beispiel #20
0
        public void Hire_Date_PropertyOK()

        {
            //an instance of the class

            ClsEmployee AnEmployee = new ClsEmployee();

            //test data

            DateTime TestData = DateTime.Now;

            //assigning data

            AnEmployee.Hire_Date = TestData;

            //test

            Assert.AreEqual(AnEmployee.Hire_Date, TestData);
        }
Beispiel #21
0
        public void Manager_ID_PropertyOK()

        {
            //an instance of the class

            ClsEmployee AnEmployee = new ClsEmployee();

            //test data

            int TestData = 100;

            //assigning data

            AnEmployee.Manager_ID = TestData;

            //test

            Assert.AreEqual(AnEmployee.Manager_ID, TestData);
        }
Beispiel #22
0
        public void Job_Name_PropertyOK()

        {
            //an instance of the class

            ClsEmployee AnEmployee = new ClsEmployee();

            //test data

            String TestData = "Test Maker";

            //assigning data

            AnEmployee.Job_Name = TestData;

            //test

            Assert.AreEqual(AnEmployee.Job_Name, TestData);
        }
        public void ThisEmployeePropertyOK()
        {
            //create an instance of the class we want to create
            clsEmployeeCollection AllEmployee = new clsEmployeeCollection();
            //create some test data to assign to the property
            ClsEmployee TestEmployee = new ClsEmployee();

            //set the properties of the test object
            TestEmployee.Emp_ID     = 113;
            TestEmployee.Emp_Name   = "Jake Wills";
            TestEmployee.Job_Name   = "Supporter";
            TestEmployee.Manager_ID = 2;
            TestEmployee.Hire_Date  = DateTime.Now.Date;
            TestEmployee.Salary     = 22000;
            TestEmployee.Dep_ID     = 3;
            TestEmployee.Active     = true;
            //assign the data to the property
            AllEmployee.ThisEmployee = TestEmployee;
            //test to see that the two values are the same
            Assert.AreEqual(AllEmployee.ThisEmployee, TestEmployee);
        }
Beispiel #24
0
        public void TestActiveFound()
        {
            //create an instance
            ClsEmployee AnEmployee = new ClsEmployee();
            //bool variable to store the result of the search
            Boolean Found = false;
            //bool variable to record if the data is OK
            Boolean OK = true;
            //test data
            int emp_ID = 21;

            //invoke the method
            Found = AnEmployee.Find(emp_ID);
            //check the employee ID
            if (AnEmployee.Active != false)
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
        public void UpdateMethodOK()
        {
            //create an instance of the class we want to create
            clsEmployeeCollection AllEmployees = new clsEmployeeCollection();
            //create the item of test data
            ClsEmployee TestEmployee = new ClsEmployee();
            //var to store the primary key
            Int32 PrimaryKey = 117;

            //set its properties
            TestEmployee.Emp_Name   = "Jake Wills";
            TestEmployee.Job_Name   = "Supporter";
            TestEmployee.Manager_ID = 2;
            TestEmployee.Hire_Date  = DateTime.Now.Date;
            TestEmployee.Salary     = 22000;
            TestEmployee.Dep_ID     = 3;
            TestEmployee.Active     = true;
            //set ThisAddress to the test data
            AllEmployees.ThisEmployee = TestEmployee;
            //add the record
            PrimaryKey = AllEmployees.Add();
            //set the primary key of the test data
            TestEmployee.Emp_ID = PrimaryKey;
            //modify the test data
            TestEmployee.Emp_Name   = "Jake Williams";
            TestEmployee.Job_Name   = "Supporter";
            TestEmployee.Manager_ID = 2;
            TestEmployee.Hire_Date  = DateTime.Now.Date;
            TestEmployee.Salary     = 22000;
            TestEmployee.Dep_ID     = 3;
            TestEmployee.Active     = true;
            //set the record based on the new test data
            AllEmployees.ThisEmployee = TestEmployee;
            //update the record
            AllEmployees.Update();
            //find the record
            AllEmployees.ThisEmployee.Find(PrimaryKey);
            //test to see ThisAddress matches the test data
            Assert.AreEqual(AllEmployees.ThisEmployee, TestEmployee);
        }
 public async Task PutEmployee(ClsEmployee employee)
 {
     var postRequest = RestService.For <IApiCore>(ConfigApi.ApiUrl);
     await postRequest.PutEmployee(employee);
 }
Beispiel #27
0
    protected void rgUsers_ItemDataBound(object sender, GridItemEventArgs e)
    {
        try
        {
            var msg = "";

            if (e.Item is GridEditFormInsertItem || e.Item is GridDataInsertItem)
            {
                UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
                //Users
                RadComboBox        cbxUsers  = userControl.FindControl("cbxUsers") as RadComboBox;
                ClsEmployee        emp       = new ClsEmployee();
                List <ClsEmployee> listUsers = emp.GetListClsEmployees();
                cbxUsers.DataTextField  = "UserName";
                cbxUsers.DataValueField = "idEmployee";
                cbxUsers.DataSource     = listUsers;
                cbxUsers.DataBind();

                //Role
                string      UserRoleHidden = (userControl.FindControl("hdnUserRole") as HiddenField).Value;
                RadComboBox cbxUserRoles   = userControl.FindControl("cbxUserRole") as RadComboBox;
                String      strConnString  = ConfigurationManager.ConnectionStrings["PurolatorReportingConnectionString"].ConnectionString;

                List <clsPI_ApplicationRole> listRoles = clsPI_ApplicationRole.GetApplicationRoles(strConnString, idPI_Application);
                cbxUserRoles.DataTextField  = "RoleName";
                cbxUserRoles.DataValueField = "ApplicationRoleId";
                cbxUserRoles.DataSource     = listRoles;
                cbxUserRoles.DataBind();

                //District
                RadComboBox        cbxDistrict   = userControl.FindControl("cbxDistrict") as RadComboBox;
                List <ClsDistrict> listDistricts = rep.GetDistricts();
                cbxDistrict.DataTextField  = "District";
                cbxDistrict.DataValueField = "District";
                cbxDistrict.DataSource     = listDistricts;
                cbxDistrict.DataBind();
            }
            else
            {
                if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode))
                {
                    //************First calling dropdown list values selected in pop up edit form**************/
                    UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
                    string      UserHidden  = (userControl.FindControl("hdnUser") as HiddenField).Value;

                    //USER NAME
                    try
                    {
                        RadComboBox        cbxUsers  = userControl.FindControl("cbxUsers") as RadComboBox;
                        ClsEmployee        emp       = new ClsEmployee();
                        List <ClsEmployee> listUsers = emp.GetListClsEmployees();

                        cbxUsers.DataTextField  = "UserName";
                        cbxUsers.DataValueField = "idEmployee";
                        cbxUsers.DataSource     = listUsers;
                        cbxUsers.DataBind();
                        cbxUsers.SelectedValue = UserHidden;
                        cbxUsers.Enabled       = false;
                    }
                    catch (Exception ex)
                    {
                        msg = ex.Message;
                    }

                    //USER ROLE
                    try
                    {
                        string      UserRoleHidden = (userControl.FindControl("hdnUserRole") as HiddenField).Value;
                        RadComboBox cbxUserRoles   = userControl.FindControl("cbxUserRole") as RadComboBox;

                        List <clsPI_ApplicationRole> listRoles = clsPI_ApplicationRole.GetApplicationRoles(strConnString, idPI_Application);

                        cbxUserRoles.DataTextField  = "RoleName";
                        cbxUserRoles.DataValueField = "ApplicationRoleId";
                        cbxUserRoles.DataSource     = listRoles;
                        cbxUserRoles.DataBind();
                        cbxUserRoles.SelectedValue = UserRoleHidden;
                    }
                    catch (Exception ex)
                    {
                        msg = ex.Message;
                    }

                    //User Restrictions
                    try
                    {
                        RadComboBox        cbxDistrict   = userControl.FindControl("cbxDistrict") as RadComboBox;
                        List <ClsDistrict> listDistricts = rep.GetDistricts();
                        cbxDistrict.DataTextField  = "District";
                        cbxDistrict.DataValueField = "District";
                        cbxDistrict.DataSource     = listDistricts;
                        cbxDistrict.DataBind();
                        RequiredFieldValidator rfDistrict = userControl.FindControl("rfDistrict") as RequiredFieldValidator;
                        Label       lblDistrict           = userControl.FindControl("lblDistrict") as Label;
                        RadComboBox cbxUserRoles          = userControl.FindControl("cbxUserRole") as RadComboBox;
                        string      UserRoleText          = cbxUserRoles.SelectedItem.Text;
                        HiddenField hdApplicationUser     = userControl.FindControl("hdnApplicationUser") as HiddenField;
                        int         idPI_ApplicationUser  = Convert.ToInt16(hdApplicationUser.Value);

                        string appname = Session["appName"].ToString();

                        switch (UserRoleText.ToLower())
                        {
                        case "salesdm":
                            string district = "";
                            //Get District for user if this a Sales District Manager
                            clsDistrictRestriction dr = new clsDistrictRestriction();
                            district = dr.GetDistrictRestriction(idPI_ApplicationUser, appname);
                            if (district != "")
                            {
                                cbxDistrict.SelectedValue = district;
                            }
                            cbxDistrict.Visible = true;
                            rfDistrict.Enabled  = true;
                            lblDistrict.Visible = true;
                            break;


                        default:
                            cbxDistrict.Visible = false;
                            rfDistrict.Enabled  = false;
                            lblDistrict.Visible = false;
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        msg = ex.Message;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            pnlDanger.Visible = true;
            lblDanger.Text    = GetCurrentMethod() + " - " + ex.Message.ToString();
        }
    }
Beispiel #28
0
 public DataTable Employee_details(ClsEmployee ObjClsEmployee)
 {
     return(objDEmployee.Employee_details(ObjClsEmployee));
 }