Ejemplo n.º 1
0
 private void ShowDepartmentsForListView(ListView lv, DepartmentArray Ds)
 {
     if (Ds != null)
     {
         lv.Items.Clear();
         for (int i = 0; i < Ds.Count; i++)
         {
             DepartmentInfo departmentInfo = Ds[i];
             ListViewItem   listViewItem   = new ListViewItem(new string[]
             {
                 departmentInfo.iDepartmentID.ToString(),
                 departmentInfo.strDepartmentName,
                 departmentInfo.strNote
             }, 0);
             listViewItem.Tag = departmentInfo.iDepartmentID.ToString("0000");
             lv.Items.Add(listViewItem);
         }
         this.toolStripStatusLabel1.Text = string.Concat(new string[]
         {
             Properties.Resources.Total,
             ": ",
             Ds.Count.ToString(),
             " ",
             Properties.Resources.Department_s_,
             "."
         });
     }
 }
Ejemplo n.º 2
0
 private void Form11_Load(object sender, EventArgs e)
 {
     this.LoadCaptionForControls();
     this.InitColumnsHeaderForListView(this.listView1);
     this.Departments = this.TheSqlData.ReaderDepartments();
     this.ShowDepartmentsForListView(this.listView1, this.Departments);
 }
Ejemplo n.º 3
0
        private void deleteDepartmentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int          num          = this.iDepartmentID;
            string       text         = this.strDepartmentName;
            DialogResult dialogResult = MessageBox.Show(string.Concat(new string[]
            {
                Properties.Resources.DoYouWantTo,
                " ",
                Properties.Resources.Delete,
                " ",
                Properties.Resources.DepartmentInfo,
                ": ",
                this.iDepartmentID.ToString(),
                ". ",
                this.strDepartmentName,
                "?"
            }), Properties.Resources.DeleteDepartment, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.OK)
            {
                if (this.TheSqlData.DeleteDepartmentInfo(this.iDepartmentID))
                {
                    this.Departments = this.TheSqlData.ReaderDepartments();
                    this.ShowDepartmentsForListView(this.listView1, this.Departments);
                    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.DepartmentInfo,
                        " ",
                        Properties.Resources.Failure,
                        "!"
                    }));
                }
            }
        }
Ejemplo n.º 4
0
        private void modifyDepartmentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DepartmentInfo departmentInfo = this.TheSqlData.ReaderDepartmentInfo(this.iDepartmentID);

            if (departmentInfo != null)
            {
                int    num = this.iDepartmentID;
                string the_strDepartmentName = departmentInfo.strDepartmentName;
                string text = departmentInfo.strNote;
                Form12 form = new Form12();
                form.bModify               = true;
                form.The_iDepartmentID     = num;
                form.The_strDepartmentName = the_strDepartmentName;
                form.The_strNote           = text;
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    the_strDepartmentName = form.The_strDepartmentName;
                    text = form.The_strNote;
                    if (this.TheSqlData.UpdateDepartmentInfo(num, the_strDepartmentName, text))
                    {
                        this.Departments = this.TheSqlData.ReaderDepartments();
                        this.ShowDepartmentsForListView(this.listView1, this.Departments);
                        this.SetListViewItemSelectFocus(this.listView1, this.iItem);
                    }
                    else
                    {
                        MessageBox.Show(string.Concat(new string[]
                        {
                            Properties.Resources.Update,
                            " ",
                            Properties.Resources.DepartmentInfo,
                            " ",
                            Properties.Resources.Failure,
                            "!"
                        }));
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void newDepartmentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool flag  = false;
            bool flag2 = true;
            int  maxValueDepartmentID = this.TheSqlData.GetMaxValueDepartmentID();

            if (maxValueDepartmentID != -1)
            {
                int    num   = maxValueDepartmentID + 1;
                string text  = "";
                string text2 = "";
                while (!flag && flag2)
                {
                    Form12 form = new Form12();
                    form.bModify               = false;
                    form.The_iDepartmentID     = num;
                    form.The_strDepartmentName = text;
                    form.The_strNote           = text2;
                    if (form.ShowDialog(this) == DialogResult.OK)
                    {
                        num   = form.The_iDepartmentID;
                        text  = form.The_strDepartmentName;
                        text2 = form.The_strNote;
                        if (!this.TheSqlData.IsExistDepartmentID(num))
                        {
                            if (this.TheSqlData.InsertDepartmentInfo(num, text, text2))
                            {
                                this.Departments = this.TheSqlData.ReaderDepartments();
                                this.ShowDepartmentsForListView(this.listView1, this.Departments);
                                this.SetListViewItemSelectFocus(this.listView1, this.listView1.Items.Count - 1);
                                flag = true;
                            }
                            else
                            {
                                MessageBox.Show(string.Concat(new string[]
                                {
                                    Properties.Resources.Insert,
                                    Properties.Resources.DepartmentInfo,
                                    " ",
                                    Properties.Resources.Failure,
                                    "!"
                                }));
                            }
                        }
                        else
                        {
                            MyMsgBox.MsgError(string.Concat(new string[]
                            {
                                Properties.Resources.InfoOfDepartment,
                                ": ",
                                num.ToString(),
                                ". ",
                                text,
                                " ",
                                Properties.Resources.IsExisted,
                                "!"
                            }));
                        }
                    }
                    else
                    {
                        flag2 = false;
                    }
                }
            }
        }
Ejemplo n.º 6
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,
                                    "!"
                                }));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
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;
                            }
                        }
                    }
                }
            }
        }