예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                form_id_HiddenField.Value      = "1";
                LangDropDownList.SelectedValue = "1";

                if (Session["tablet_mode"] != null)
                {
                    if (Session["tablet_mode"].ToString() == "1")
                    {
                        if (Session["id"] != null)
                        {
                            form_id_HiddenField.Value      = Session["id"].ToString();
                            LangDropDownList.SelectedValue = Session["id"].ToString();
                        }

                        if (Session["badge_id"] != null)
                        {
                            BadgeTextBox.Text = Session["badge_id"].ToString();

                            // byte[] bytes = MarshFormsFunctions.GetEmployeeBadgeImage(Session["badge_id"]);
                            // BitmapImage bmpImage = new BitmapImage();
                            // MemoryStream msImageStream = new MemoryStream();
                            // msImageStream.Write(bytes, 0, bytes.Length);
                            // bmpCardImage.BeginInit();
                            // bmpCardImage.StreamSource = new MemoryStream(msImageStream.ToArray());
                            // bmpCardImage.EndInit();
                            //// image.Source = bmpCardImage;
                            // BadgeImage.ImageUrl =   MarshFormsFunctions.GetEmployeeBadgeImage(Session["badge_id"].ToString());

                            TemperatureTextBox.Text = MarshFormsFunctions.GetLastTemp(Session["badge_id"].ToString());
                        }

                        if (Session["employee_name"] != null)
                        {
                            EmployeeNameTextBox.Text = Session["employee_name"].ToString();
                        }


                        if (Session["max_dt"] != null)
                        {
                            LastSurveyedLabel.Text = Session["max_dt"].ToString();
                        }
                    }
                    else if (Session["tablet_mode"].ToString() == "0")
                    {
                    }
                }
                else
                {
                }

                EmployeeNameTextBox.Focus();
            }

            //EmployeeNameTextBox.Focus();
        }
        private void ClearButton_Click(object sender, EventArgs e)
        {
            //Clear all of the form's text fields

            EmployeeSalesBonusTextBox.Clear();
            EmployeeNameTextBox.Clear();
            EmployeeIdTextBox.Clear();
            EmployeeTotalSalesTextBox.Clear();
        }
 private void ClearAddEmployee(object sender, DialogClosingEventArgs eventArgs)
 {
     EmployeeNameTextBox.Clear();
     EmployeeAddressTextBox.Clear();
     EmployeeBirthDatePicker.SelectedDate = DateTime.Today;
     EmployeeSalaryTextBox.Clear();
     EmployeeDepartmentComboBox.SelectedItem = null;
     EmpoloyeeRoleComboBox.SelectedItem      = null;
     validation.Text = "";
 }
 public void addEmployee(object sender, RoutedEventArgs e)
 {
     if (ViewModel.ValidateName())
     {
         ViewModel.addEmployee();
         EmployeeNameTextBox.Clear();
         EmployeeAddressTextBox.Clear();
         EmployeeBirthDatePicker.SelectedDate = DateTime.Today;
         EmployeeSalaryTextBox.Clear();
         EmployeeDepartmentComboBox.SelectedItem = null;
         EmpoloyeeRoleComboBox.SelectedItem      = null;
         Home.ViewModel.CloseRootDialog();
     }
 }
 private bool IsFormValid()
 {
     if (EmployeeNameTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("Name is required");
         EmployeeNameTextBox.Focus();
         return(false);
     }
     if (CNICTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("CNIC is required");
         CNICTextBox.Focus();
         return(false);
     }
     if ((TelephoneTextBox.Text.Trim() == string.Empty) && (MobileTextBox.Text.Trim() == string.Empty))
     {
         Messages.ShowErrorMessage("Mobile number or Telephone number is required");
         MobileTextBox.Focus();
         return(false);
     }
     if (GenderComboBox.SelectedIndex == -1)
     {
         Messages.ShowErrorMessage("Gender is required");
         GenderComboBox.Focus();
         return(false);
     }
     //if (BranchComboBox.SelectedIndex == -1)
     //{
     //	Messages.ShowErrorMessage("Branch is required");
     //	BranchComboBox.Focus();
     //	return false;
     //}
     if (AddressLineTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("Address Line is required");
         AddressLineTextBox.Focus();
         return(false);
     }
     if (CityComboBox.SelectedIndex == -1)
     {
         Messages.ShowErrorMessage("City is required");
         CityComboBox.Focus();
         return(false);
     }
     if (DistrictComboBox.SelectedIndex == -1)
     {
         Messages.ShowErrorMessage("District is required");
         DistrictComboBox.Focus();
         return(false);
     }
     if (PostalCodeTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("Postal Code is required");
         PostalCodeTextBox.Focus();
         return(false);
     }
     if (JobTitleComboBox.SelectedIndex == -1)
     {
         Messages.ShowErrorMessage("Job Title is required");
         JobTitleComboBox.Focus();
         return(false);
     }
     if (StartingSalaryTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("Starting Salary is required");
         StartingSalaryTextBox.Focus();
         return(false);
     }
     else
     {
         if (Convert.ToDecimal(StartingSalaryTextBox.Text) <= 0)
         {
             Messages.ShowErrorMessage("Starting Salary cannot be zero or less than zero");
             StartingSalaryTextBox.Focus();
             return(false);
         }
     }
     if (CurrentSalaryTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("Current Salary is required");
         CurrentSalaryTextBox.Focus();
         return(false);
     }
     else
     {
         if (Convert.ToDecimal(CurrentSalaryTextBox.Text) <= 0)
         {
             Messages.ShowErrorMessage("Current Salary cannot be zero or less than zero");
             CurrentSalaryTextBox.Focus();
             return(false);
         }
     }
     return(true);
 }
 //Method to clear the form and reset focus
 private void ClearButton_Click(object sender, EventArgs e)
 {
     ClearForm();
     EmployeeNameTextBox.Focus();
 }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (EmployeeIdTextBox.Text.Trim() == "" || EmployeeNameTextBox.Text.Trim() == "" || RankTextBox.Text.Trim() == "" || FacutlyComboBox.SelectedItem == null || DepartmentComboBox.SelectedItem == null || CenterComboBox.SelectedItem == null || BuildingComboBox.SelectedItem == null || LevelComboBox.SelectedItem == null)
            {
                MessageBox.Show("Sorry! Fields cannot be empty!", "Error");
                return;
            }
            Lecturer lecturer = new Lecturer
            {
                EmployeeId   = Int32.Parse(EmployeeIdTextBox.Text.Trim()),
                EmployeeName = EmployeeNameTextBox.Text.Trim(),
                Rank         = float.Parse(RankTextBox.Text.Trim())
            };

            string facultyName    = FacutlyComboBox.SelectedItem.ToString();
            string departmentName = DepartmentComboBox.SelectedItem.ToString();
            string centerName     = CenterComboBox.SelectedItem.ToString();
            string buildingName   = BuildingComboBox.SelectedItem.ToString();
            string levelName      = LevelComboBox.SelectedItem.ToString();

            LecturerDataService lecturerDataService = new LecturerDataService(new EntityFramework.TimetableManagerDbContext());

            if (!EmployeeIdTextBox.IsEnabled)
            {
                EmployeeIdTextBox.IsEnabled = true;

                lecturerDataService.UpdateLecturer(lecturer, facultyName, departmentName, centerName, buildingName, levelName).ContinueWith(result =>
                {
                    if (result != null)
                    {
                        MessageBox.Show("Lecture Updated!", "Success");
                    }
                    else
                    {
                        MessageBox.Show("Sorry! Error occured!", "Error");
                    }
                });
            }
            else
            {
                lecturerDataService.AddLecturer(lecturer, facultyName, departmentName, centerName, buildingName, levelName).ContinueWith(result =>
                {
                    if (result != null)
                    {
                        MessageBox.Show("Lecture Added!", "Success");
                    }
                    else
                    {
                        MessageBox.Show("Sorry! Error occured!", "Error");
                    }
                });
            }

            EmployeeIdTextBox.Clear();
            EmployeeNameTextBox.Clear();
            RankTextBox.Clear();
            FacutlyComboBox.SelectedIndex    = -1;
            DepartmentComboBox.SelectedIndex = -1;
            CenterComboBox.SelectedIndex     = -1;
            BuildingComboBox.SelectedIndex   = -1;
            LevelComboBox.SelectedIndex      = -1;

            LecturerDataList.Clear();
            _ = this.LoadLecturerData();
        }
예제 #8
0
        protected void SubmitLinkButton_Click(object sender, EventArgs e)
        {
            String employee_name       = EmployeeNameTextBox.Text;
            String employee_badge_id   = BadgeTextBox.Text;
            String temperature         = TemperatureTextBox.Text;
            String additional_comments = AdditionalCommentsTextBox.Text;
            bool   NoBlanks            = true;

            if (employee_name == "")
            {
                NoBlanks = false;
                EmployeeNameTextBox.Focus();
                MessageLabel.Text = "Employee name field must be filled in.";
            }
            else if (employee_badge_id == "")
            {
                NoBlanks = false;
                BadgeTextBox.Focus();
            }
            //REMOVED 10/5/2020

            /*else if (temperature == "")
             * {
             *   NoBlanks = false;
             *   TemperatureTextBox.Focus();
             * }*/
            else
            {
                int    employee_id = MarshFormsFunctions.GetEmployeeID(Convert.ToInt32(employee_badge_id));
                int    payroll_id  = MarshFormsFunctions.GetEmployeePayrollIDFromBadge(employee_badge_id);
                String g           = Guid.NewGuid().ToString();
                //IDictionary<int, string> answers = new Dictionary<int, string>();
                List <List <string> > answers = new List <List <string> >();

                bool answeredTrue       = false;
                int  critical_count     = 0;
                int  non_critical_count = 0;
                foreach (ListViewItem lvi1 in question_headings_ListView.Items)
                {
                    ListView questions_ListView = (ListView)lvi1.FindControl("questions_ListView");

                    foreach (ListViewItem lvi2 in questions_ListView.Items)
                    {
                        int question_id;
                        if (Int32.TryParse(questions_ListView.DataKeys[lvi2.DataItemIndex].Values["id"].ToString(), out question_id))
                        {
                            CheckBox answer1bit        = (CheckBox)lvi2.FindControl("answer1bit");
                            CheckBox answer2bit        = (CheckBox)lvi2.FindControl("answer2bit");
                            CheckBox answer3bit        = (CheckBox)lvi2.FindControl("answer3bit");
                            String   critical_question = questions_ListView.DataKeys[lvi2.DataItemIndex].Values["critical"].ToString();

                            answers.Add(new List <string> {
                                question_id.ToString(), answer1bit.Checked.ToString(), answer2bit.Checked.ToString(), answer3bit.Checked.ToString()
                            });


                            if (answer1bit.Checked || answer2bit.Checked)
                            {
                                //answers.Add(question_id, "True");
                                answeredTrue = true;
                                if (critical_question == "True")
                                {
                                    critical_count++;
                                }
                                else
                                {
                                    non_critical_count++;
                                }
                            }
                            else if (answer3bit.Checked)
                            {
                                //answers.Add(question_id, "False");
                            }
                            else
                            {
                                //answers.Add(question_id, "Blank");
                                NoBlanks = false;
                            }
                        }
                    }
                }

                ////ERROR CHECKING


                if (NoBlanks)
                {
                    if (!MarshFormsFunctions.SubmitTemp(employee_id, employee_name, employee_badge_id, temperature, g, additional_comments))
                    {
                        //ERROR database exception
                        MessageLabel.Text = "An unexpected error occurred when trying to submit the form. Please try again.";
                    }
                    else
                    {
                        foreach (List <string> subList in answers)
                        {
                            int    question_id;
                            String answer1 = "";
                            String answer2 = "";
                            String answer3 = "";
                            if (Int32.TryParse(subList[0], out question_id))
                            {
                                answer1 = subList[1];
                                answer2 = subList[2];
                                answer3 = subList[3];
                            }


                            if (!MarshFormsFunctions.SubmitAnswer1(question_id, employee_id, employee_name, employee_badge_id, answer1, answer2, answer3, g))
                            {
                                //ERROR database exception
                                MessageLabel.Text = "An unexpected error occurred when trying to submit the form. Please try again.";
                                break;
                            }
                        }

                        //IF THERE TEMP IS HIGH THEN GRAB A PHONE # AND GO TO YOUR CAR

                        if (temperature != "")
                        {
                            if (double.Parse(temperature, System.Globalization.CultureInfo.InvariantCulture) >= 100.4)
                            {
                                HttpContext.Current.Session["guid"] = g;
                                Response.Redirect("~\\FormSubmittedTrue.aspx");
                            }
                        }


                        //IF THEY ARE IN THE PROGRAM THEN BUSINESS AS USUAL
                        if (MarshFormsFunctions.get_monitor(employee_badge_id))
                        {
                            //MarshFormsFunctions.sendEmail(g, employee_name, "", true, payroll_id.ToString());
                            Response.Redirect("~\\FormSubmitted.aspx");
                        }


                        //ANY AMOUNT OF YES -- GO TO CAR
                        //else if (answeredTrue)
                        //{
                        //    HttpContext.Current.Session["guid"] = g;
                        //    Response.Redirect("~\\FormSubmittedTrue.aspx");
                        //}
                        //IF YOU ANSWER 1 OR MORE CRITICAL QUESTIONS TRUE THEN GO TO YOUR CAR
                        else if (critical_count > 0)
                        {
                            HttpContext.Current.Session["guid"] = g;
                            Response.Redirect("~\\FormSubmittedTrue.aspx");
                        }
                        //IF YOU ANSWER 2 OR MORE SOFT QUESTIONS TRUE THEN GO TO YOUR CAR
                        else if (non_critical_count > 1)
                        {
                            HttpContext.Current.Session["guid"] = g;
                            Response.Redirect("~\\FormSubmittedTrue.aspx");
                        }

                        //OTHERWISE YOUR GOOD TO STAY IN THE FACILITY
                        else
                        {
                            //SEND FOLLOW UP EMAIL IF THERE IS ONE SOFT YES
                            if (non_critical_count > 0)
                            {
                                MarshFormsFunctions.sendEmail(g, employee_name, "", true, payroll_id.ToString());
                            }
                            Response.Redirect("~\\FormSubmitted.aspx");
                        }
                    }
                }
                else
                {
                    // MessageLabel.Text = "Please be sure to fill out each field on the form.";
                    //ERROR blank value
                }
            }
        }