Beispiel #1
0
 private void Form10_Load(object sender, EventArgs e)
 {
     this.LoadCaptionForControls();
     this.InitColumnsHeaderForListView(this.listView1);
     this.Employees = this.TheSqlData.ReaderEmployees();
     this.ShowEmployeesForListView(this.listView1, this.Employees);
 }
Beispiel #2
0
        private void deleteEmployeeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int          num          = this.iEmployeeID;
            string       text         = this.strEmployeeName;
            DialogResult dialogResult = MessageBox.Show(string.Concat(new string[]
            {
                Properties.Resources.DoYouWantTo,
                " ",
                Properties.Resources.Delete,
                " ",
                Properties.Resources.EmployeeInfo,
                ": ",
                this.iEmployeeID.ToString(),
                ". ",
                this.strEmployeeName,
                "?"
            }), Properties.Resources.DeleteEmployee, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.OK)
            {
                if (this.TheSqlData.DeleteEmployeeInfo(this.iEmployeeID))
                {
                    this.Employees = this.TheSqlData.ReaderEmployees();
                    this.ShowEmployeesForListView(this.listView1, this.Employees);
                    this.SetListViewItemSelectFocus(this.listView1, (this.listView1.Items.Count > this.iItem) ? this.iItem : (this.iItem - 1));
                }
                else
                {
                    MessageBox.Show(string.Concat(new string[]
                    {
                        Properties.Resources.DeleteU,
                        " ",
                        Properties.Resources.EmployeeInfo,
                        " ",
                        Properties.Resources.Failure,
                        "!"
                    }));
                }
            }
        }
Beispiel #3
0
 private void ShowEmployeesForListView(ListView lv, EmployeeArray Es)
 {
     if (Es != null)
     {
         lv.Items.Clear();
         for (int i = 0; i < Es.Count; i++)
         {
             EmployeeInfo employeeInfo = Es[i];
             ListViewItem listViewItem = new ListViewItem(new string[]
             {
                 employeeInfo.iEmployeeID.ToString(),
                 employeeInfo.strFirstName.Trim() + " " + employeeInfo.strLastName.Trim(),
                 employeeInfo.bMenOrWomen ? Properties.Resources.Men : Properties.Resources.Women,
                 employeeInfo.dtBirthDate.ToString("dd/MM/yyyy"),
                 employeeInfo.strTitle,
                 employeeInfo.strDepartmentName,
                 employeeInfo.strJobName,
                 employeeInfo.dtHireDate.ToString("dd/MM/yyyy"),
                 employeeInfo.strAddress,
                 employeeInfo.strCity,
                 employeeInfo.strPhone,
                 employeeInfo.strNote
             }, 0);
             listViewItem.Tag = employeeInfo.iEmployeeID.ToString("0000");
             lv.Items.Add(listViewItem);
         }
         this.toolStripStatusLabel1.Text = string.Concat(new string[]
         {
             Properties.Resources.Total,
             ": ",
             Es.Count.ToString(),
             " ",
             Properties.Resources.Employee_s_,
             "."
         });
     }
 }
Beispiel #4
0
        private void modifyEmployeeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EmployeeInfo employeeInfo = this.TheSqlData.ReaderEmployeeInfo(this.iEmployeeID);

            if (employeeInfo != null)
            {
                int             num             = this.iEmployeeID;
                string          text            = employeeInfo.strFirstName;
                string          text2           = employeeInfo.strLastName;
                bool            flag            = employeeInfo.bMenOrWomen;
                DateTime        dateTime        = employeeInfo.dtBirthDate;
                string          text3           = employeeInfo.strTitle;
                DepartmentArray departmentArray = this.TheSqlData.ReaderDepartments();
                if (departmentArray.Count != 0)
                {
                    string[] array = new string[departmentArray.Count];
                    for (int i = 0; i < departmentArray.Count; i++)
                    {
                        array[i] = departmentArray[i].strDepartmentName;
                    }
                    int[] array2 = new int[departmentArray.Count];
                    for (int i = 0; i < departmentArray.Count; i++)
                    {
                        array2[i] = departmentArray[i].iDepartmentID;
                    }
                    JobArray jobArray = this.TheSqlData.ReaderJobs();
                    if (jobArray.Count != 0)
                    {
                        string[] array3 = new string[jobArray.Count];
                        for (int i = 0; i < jobArray.Count; i++)
                        {
                            array3[i] = jobArray[i].strJobName;
                        }
                        int[] array4 = new int[jobArray.Count];
                        for (int i = 0; i < jobArray.Count; i++)
                        {
                            array4[i] = jobArray[i].iJobID;
                        }
                        int      num2 = employeeInfo.iDepartmentID;
                        string   strDepartmentName = employeeInfo.strDepartmentName;
                        int      num3       = employeeInfo.iDepartmentID;
                        string   strJobName = employeeInfo.strJobName;
                        DateTime dateTime2  = employeeInfo.dtHireDate;
                        string   text4      = employeeInfo.strAddress;
                        string   text5      = employeeInfo.strCity;
                        string   text6      = employeeInfo.strPhone;
                        string   text7      = employeeInfo.strNote;
                        Form9    form       = new Form9();
                        form.bModify               = true;
                        form.The_DepartmentNames   = array;
                        form.The_DepartmentIDs     = array2;
                        form.The_JobNames          = array3;
                        form.The_JobIDs            = array4;
                        form.The_iEmployeeID       = num;
                        form.The_strFirstName      = text;
                        form.The_strLastName       = text2;
                        form.The_bMenOrWomen       = flag;
                        form.The_dtBirthDate       = dateTime;
                        form.The_strTitle          = text3;
                        form.The_iDepartmentID     = num2;
                        form.The_strDepartmentName = strDepartmentName;
                        form.The_iJobID            = num3;
                        form.The_strJobName        = strJobName;
                        form.The_dtHireDate        = dateTime2;
                        form.The_strAddress        = text4;
                        form.The_strCity           = text5;
                        form.The_strPhone          = text6;
                        form.The_strNote           = text7;
                        if (form.ShowDialog(this) == DialogResult.OK)
                        {
                            text      = form.The_strFirstName;
                            text2     = form.The_strLastName;
                            flag      = form.The_bMenOrWomen;
                            dateTime  = form.The_dtBirthDate;
                            text3     = form.The_strTitle;
                            num2      = form.The_iDepartmentID;
                            num3      = form.The_iJobID;
                            dateTime2 = form.The_dtHireDate;
                            text4     = form.The_strAddress;
                            text5     = form.The_strCity;
                            text6     = form.The_strPhone;
                            text7     = form.The_strNote;
                            if (this.TheSqlData.UpdateEmployeeInfo(num, text, text2, flag, dateTime, text3, num2, num3, dateTime2, text4, text5, text6, text7))
                            {
                                this.Employees = this.TheSqlData.ReaderEmployees();
                                this.ShowEmployeesForListView(this.listView1, this.Employees);
                                this.SetListViewItemSelectFocus(this.listView1, this.iItem);
                            }
                            else
                            {
                                MessageBox.Show(string.Concat(new string[]
                                {
                                    Properties.Resources.Update,
                                    " ",
                                    Properties.Resources.EmployeeInfo,
                                    " ",
                                    Properties.Resources.Failure,
                                    "!"
                                }));
                            }
                        }
                    }
                }
            }
        }
Beispiel #5
0
        private void newEmployeeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool flag  = false;
            bool flag2 = true;
            int  maxValueEmployeeID = this.TheSqlData.GetMaxValueEmployeeID();

            if (maxValueEmployeeID != -1)
            {
                int             num             = maxValueEmployeeID + 1;
                string          text            = "";
                string          text2           = "";
                bool            flag3           = false;
                DateTime        the_dtBirthDate = new DateTime(1900, 1, 1);
                string          text3           = "";
                DepartmentArray departmentArray = this.TheSqlData.ReaderDepartments();
                if (departmentArray.Count != 0)
                {
                    string[] array = new string[departmentArray.Count];
                    for (int i = 0; i < departmentArray.Count; i++)
                    {
                        array[i] = departmentArray[i].strDepartmentName;
                    }
                    int[] array2 = new int[departmentArray.Count];
                    for (int i = 0; i < departmentArray.Count; i++)
                    {
                        array2[i] = departmentArray[i].iDepartmentID;
                    }
                    JobArray jobArray = this.TheSqlData.ReaderJobs();
                    if (jobArray.Count != 0)
                    {
                        string[] array3 = new string[jobArray.Count];
                        for (int i = 0; i < jobArray.Count; i++)
                        {
                            array3[i] = jobArray[i].strJobName;
                        }
                        int[] array4 = new int[jobArray.Count];
                        for (int i = 0; i < jobArray.Count; i++)
                        {
                            array4[i] = jobArray[i].iJobID;
                        }
                        int      num2 = 0;
                        string   the_strDepartmentName = "";
                        int      num3           = 0;
                        string   the_strJobName = "";
                        DateTime the_dtHireDate = new DateTime(1900, 1, 1);
                        string   text4          = "";
                        string   text5          = "";
                        string   text6          = "";
                        string   text7          = "";
                        while (!flag && flag2)
                        {
                            Form9 form = new Form9();
                            form.bModify               = false;
                            form.The_DepartmentNames   = array;
                            form.The_DepartmentIDs     = array2;
                            form.The_JobNames          = array3;
                            form.The_JobIDs            = array4;
                            form.The_iEmployeeID       = num;
                            form.The_strFirstName      = text;
                            form.The_strLastName       = text2;
                            form.The_bMenOrWomen       = flag3;
                            form.The_dtBirthDate       = the_dtBirthDate;
                            form.The_strTitle          = text3;
                            form.The_iDepartmentID     = num2;
                            form.The_strDepartmentName = the_strDepartmentName;
                            form.The_iJobID            = num3;
                            form.The_strJobName        = the_strJobName;
                            form.The_dtHireDate        = the_dtHireDate;
                            form.The_strAddress        = text4;
                            form.The_strCity           = text5;
                            form.The_strPhone          = text6;
                            form.The_strNote           = text7;
                            if (form.ShowDialog(this) == DialogResult.OK)
                            {
                                num                   = form.The_iEmployeeID;
                                text                  = form.The_strFirstName;
                                text2                 = form.The_strLastName;
                                flag3                 = form.The_bMenOrWomen;
                                the_dtBirthDate       = form.The_dtBirthDate;
                                text3                 = form.The_strTitle;
                                num2                  = form.The_iDepartmentID;
                                the_strDepartmentName = form.The_strDepartmentName;
                                the_strJobName        = form.The_strJobName;
                                num3                  = form.The_iJobID;
                                the_dtHireDate        = form.The_dtHireDate;
                                text4                 = form.The_strAddress;
                                text5                 = form.The_strCity;
                                text6                 = form.The_strPhone;
                                text7                 = form.The_strNote;
                                if (!this.TheSqlData.IsExistEmployeeID(num))
                                {
                                    if (this.TheSqlData.InsertEmployeeInfo(num, text, text2, flag3, the_dtBirthDate, text3, num2, num3, the_dtHireDate, text4, text5, text6, text7))
                                    {
                                        this.Employees = this.TheSqlData.ReaderEmployees();
                                        this.ShowEmployeesForListView(this.listView1, this.Employees);
                                        this.SetListViewItemSelectFocus(this.listView1, this.listView1.Items.Count - 1);
                                        flag = true;
                                    }
                                    else
                                    {
                                        MessageBox.Show(string.Concat(new string[]
                                        {
                                            Properties.Resources.Insert,
                                            Properties.Resources.EmployeeInfo,
                                            " ",
                                            Properties.Resources.Failure,
                                            "!"
                                        }));
                                    }
                                }
                                else
                                {
                                    MyMsgBox.MsgError(string.Concat(new string[]
                                    {
                                        Properties.Resources.InfoOfEmployee,
                                        ": ",
                                        num.ToString(),
                                        ". ",
                                        text,
                                        " ",
                                        text2,
                                        " ",
                                        Properties.Resources.IsExisted,
                                        "!"
                                    }));
                                }
                            }
                            else
                            {
                                flag2 = false;
                            }
                        }
                    }
                }
            }
        }