Esempio n. 1
0
        private void GenInvoice_Click(object sender, EventArgs e)
        {
            //string deduct = DeductionsText.Text;
            //string net = NetPayText.Text;
            if (EmployeeNameText.Text != "" && DepartmentText.Text != "" && GrossPayText.Text != "" && DeductionsText.Text != "" && NetPayText.Text != "")
            //if(string.IsNullOrEmpty(employeename + department + grosspay.ToString() + deduct + net))
            {
                EmptyError.Hide();
                employeename = EmployeeNameText.Text;
                date         = DatePicker.Text;
                weeks        = (int)WeekChooser.Value;
                department   = DepartmentText.Text;
                hours        = (int)HoursWorked.Value;
                directory    = DirectoryText.Text;
                if (System.IO.Directory.Exists(directory))
                {
                    string path = directory + @"\" + employeename + @" Payslip.txt";
                    if (!System.IO.File.Exists(path))
                    {
                        string[] createText = { "Pay Slip",
                                                "\n ==================== \n",
                                                "Employer Name: iTec-Ming-Ming corp.",
                                                "Name: " + employeename,
                                                "Department: " + department,
                                                "\n -------------------- \n",
                                                "Date of Pay: " + date.ToString(),
                                                "Week Number: " + weeks.ToString(),
                                                "Hours Worked: " + hours.ToString(),
                                                "\n -------------------- \n",
                                                "Gross Pay: " + GrossPayText.Text,
                                                "Deductions: " + DeductionsText.Text,
                                                "Net Pay: " + NetPayText.Text,
                                                "\n ==================== \n",
                                                "This Serves as Official Payslip for " + employeename,
                                                "Date of Payment: " + DateTime.Now.ToShortDateString(),
                                                "Date Printed: " + DateTime.Now.ToLongDateString(),
                                                "\n ==================== \n", };

                        System.IO.File.WriteAllLines(path, createText);
                        MessageBox.Show("Payslip has been created for " + employeename, "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Payslip for " + employeename + " already exists!", "Opps! Something went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                }
                else
                {
                    MessageBox.Show("The directory does not exist!", "Opps! Something went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    DirErrorLabel.Show();
                }
            }
            else
            {
                EmptyError.Show();
            }
        }
Esempio n. 2
0
 private void InvoicesButton_Click(object sender, EventArgs e)
 {
     directory = DirectoryText.Text;
     if (System.IO.Directory.Exists(directory))
     {
         Process.Start(directory);
         DirErrorLabel.Hide();
     }
     else
     {
         MessageBox.Show("The directory path is not set or does not exist!", "Opps! Something went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
         DirErrorLabel.Show();
     }
 }