private void PopulatePositionListView()
        {
            dsPosition = departmentDO.GetAllGroupDepartments();

            lvwPosition.BeginUpdate();
            lvwPosition.TableModel.Rows.Clear();
            dtPosition = dsPosition.Tables[0];
            if (dtPosition.Rows.Count > 0)
            {
                //				selectedRowIndex = 0;
                int STT = 0;
                foreach (DataRow dr in dtPosition.Rows)
                {
                    STT++;
                    string PositionName      = dr["GroupName"].ToString();
                    string PositionShortName = dr["GroupID"].ToString();
                    string Description       = dr["GroupDescription"].ToString();

                    Row row = new Row(new string[] { STT.ToString(), PositionName, PositionShortName, Description });
                    row.Tag = STT - 1;
                    lvwPosition.TableModel.Rows.Add(row);
                }
            }
            lvwPosition.EndUpdate();
        }
Exemple #2
0
        private void frmDepartment_Load(object sender, EventArgs e)
        {
            Refresh();
            departmentDO = new DepartmentDO();
            DataSet dsDepartmentGroup = new DataSet();

            dsDepartmentGroup = departmentDO.GetAllGroupDepartments();
            if (dsDepartmentGroup != null)
            {
                cboGroup.SourceDataString = new string[] { "GroupID", "GroupName" };
                cboGroup.SourceDataTable  = dsDepartmentGroup.Tables[0];
                cboGroup.SelectedIndex    = 0;
            }
            if (DepartmentName != "")
            {
                string str = WorkingContext.LangManager.GetString("frmDep_Text1");
                //this.Text = "Sửa thông tin phòng ban";
                this.Text = str;
                txtDepartmentName.Text = DepartmentName;
                txtDescription.Text    = Description;
                if (SortIndex > 0)
                {
                    txtSort.Text = SortIndex.ToString();
                }
                else
                {
                    txtSort.Text = "1";
                    SortIndex    = 1;
                }

                DataSet dsGroupName = departmentDO.GetGroupDepartments(GroupID);
                if (dsGroupName != null)
                {
                    cboGroup.Text = dsGroupName.Tables[0].Rows[0]["GroupName"].ToString();
                }
            }
            else
            {
                string str = WorkingContext.LangManager.GetString("frmDep_Text2");
                //this.Text = "Thêm một phòng ban mới";
                this.Text = str;
            }
        }
Exemple #3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtPositionName.Text.Trim() == "")
            {
                //string str = WorkingContext.LangManager.GetString("frmPosition_Add_Error_Messa1");
                //string str1 = WorkingContext.LangManager.GetString("frmPosition_Add_Error_Title1");
                MessageBox.Show("Bạn chưa nhập tên nhóm phòng ban!", "Lỗi nhập dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (txtPositionShortName.Text.Trim() == "")
            {
                //string str = WorkingContext.LangManager.GetString("frmPosition_Add_Error_Messa2");
                //string str1 = WorkingContext.LangManager.GetString("frmPosition_Add_Error_Title1");
                MessageBox.Show("Bạn chưa nhập mã phòng ban tắt!", "Lỗi nhập dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                decimal.Parse(txtPositionShortName.Text);
            }
            catch
            {
                MessageBox.Show("Mã nhóm là kiểu số !", "Lỗi nhập dữ liệu");
                return;
            }

            string groupName   = string.Empty;
            int    groupID     = 0;
            string description = String.Empty;

            if (selectedPosition < 0)
            {
                groupName   = txtPositionName.Text.Trim();
                groupID     = Convert.ToInt32(txtPositionShortName.Text.Trim());
                description = txtDescription.Text;

                int result = departmentDO.AddDepartmentGroup(groupID, groupName, description);
                if (result == 2)
                {
                    //string str = WorkingContext.LangManager.GetString("frmPosition_Add_ThongBao_Messa");
                    //string str1 = WorkingContext.LangManager.GetString("frmPosition_Add_ThongBao_Title");
                    MessageBox.Show("Thêm nhóm phòng ban thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dsPosition = departmentDO.GetAllGroupDepartments();
                    dsPosition.AcceptChanges();
                    this.Close();
                }
                if (result == 1)
                {
                    //string str = WorkingContext.LangManager.GetString("frmPosition_Add_CanhBao_Messa");
                    //string str1 = WorkingContext.LangManager.GetString("frmPosition_Add_ThongBao_Title");
                    MessageBox.Show("Tên nhóm hoặc mã nhóm đã tồn tại trong hệ thống !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    //MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dsPosition.RejectChanges();
                }
            }
            else
            {
                groupName   = txtPositionName.Text.Trim();
                groupID     = Convert.ToInt32(txtPositionShortName.Text.Trim());
                description = txtDescription.Text;

                int result = departmentDO.UpdateDepartmentGroup(groupID, groupName, description);
                dsPosition.AcceptChanges();
                if (result == 2)
                {
                    //string str = WorkingContext.LangManager.GetString("frmPosition_UpDate_ThongBao_Messa");
                    //string str1 = WorkingContext.LangManager.GetString("frmPosition_UpDate_ThongBao_Title");
                    MessageBox.Show("Cập nhật nhóm phòng ban thành công!", "Cập nhật", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dsPosition = departmentDO.GetAllGroupDepartments();
                    dsPosition.AcceptChanges();
                    this.Close();
                }
                if (result == 1)
                {
                    //string str = WorkingContext.LangManager.GetString("frmPosition_Add_CanhBao_Messa");
                    //string str1 = WorkingContext.LangManager.GetString("frmPosition_UpDate_ThongBao_Title");
                    MessageBox.Show("Tên nhóm phòng ban đã tồn tại trong hệ thống !", "Cập nhật", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    //MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dsPosition.RejectChanges();
                }
            }
        }