예제 #1
0
        private void clockInBtn_Click(object sender, EventArgs e)
        {
            if (validateFormData())
            {
                try
                {
                    TimeCard tc = new TimeCard();
                    tc.Employee = this.currEmp;
                    tc.WorkSite = (WorkSite)this.workSiteCmbo.SelectedItem;
                    tc.Job = (Job)this.jobCmbo.SelectedItem;
                    LaborService.LaborServiceClient proxy = new LaborService.LaborServiceClient();
                    //proxy.ClientCredentials.UserName.UserName = "******";
                    //proxy.ClientCredentials.UserName.Password = "******";
                    proxy.doClockIn(tc);
                }
                catch (FaultException ex)
                {
                    MessageBox.Show(this, "Server Error occurred during processing of Clock In.  See Server logs for details (i.e. Call Jim and cry for help!)", "Server Error");
                }

                this.Close();
            }
        }
예제 #2
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            try
            {
                this.Enabled = false;

                int loginId = -1;
                Employee emp = new Employee();

                try
                {
                    loginId = Int32.Parse(this.loginInputTxt.Text);
                }
                catch (FormatException)
                {
                    this.loginMessageTxt.ForeColor = Color.Red;
                    this.loginMessageTxt.Text = MESSAGE_INVALID_LOGINID;
                    this.loginInputTxt.Focus();
                }

                try
                {
                    LaborService.LaborServiceClient proxy = new LaborService.LaborServiceClient();
                    //proxy.ClientCredentials.UserName.UserName = "******";
                    //proxy.ClientCredentials.UserName.Password = "******";

                    if (proxy.isValidLogin(loginId))
                    {
                        emp = proxy.getEmployee(loginId);

                        if (emp.IsClockedIn)
                        {
                            TimeCard currTimeCard = proxy.getLatestOpenTimeCard(emp.EmployeeId);
                            currTimeCard.Employee = emp;
                            ClockOutForm clockOutForm = new ClockOutForm(this, currTimeCard);
                            this.loginInputTxt.Text = string.Empty;
                            this.loginMessageTxt.Text = MESSAGE_ENTER_ID;
                            this.loginMessageTxt.ForeColor = Color.Black;
                            this.Hide();
                            clockOutForm.Show();
                        }
                        else
                        {
                            List<WorkSite> workSiteList = proxy.getWorkSiteList().ToList();
                            List<Job> jobList = proxy.getJobList(emp.EmployeeId).ToList();

                            ClockInForm clockInForm = new ClockInForm(this, emp, workSiteList, jobList);
                            this.loginInputTxt.Text = string.Empty;
                            this.loginMessageTxt.Text = MESSAGE_ENTER_ID;
                            this.loginMessageTxt.ForeColor = Color.Black;
                            this.Hide();
                            clockInForm.Show();
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.loginMessageTxt.ForeColor = Color.Red;
                    this.loginMessageTxt.Text = MESSAGE_SERVER_ERROR;
                    logger.Error(ex.ToString());
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
            }
            finally
            {
                this.Enabled = true;
            }
        }