Example #1
0
        private void btn_Them_Click(object sender, EventArgs e)
        {
            if (btn_Edit_Luong.ImageKey != "Save.png")
            {
                if (thongTinQuyetDinh1.txt_MaQD.Text != "" && thongTinQuyetDinh1.txt_TenQD.Text != "")
                {
                    if (CheckNgachMoi_NgachCu())
                    {
                        if (MessageBox.Show("Bạn thực sự muốn lưu thông tin lương ngạch cho các nhân viên này?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            try
                            {
                                #region Get thong tin luong

                                int n = kvpLuongID.Count;

                                int[]      luong_id          = new int[n];
                                string[]   ma_nv             = new string[n];
                                int[]      ngach_bac_heso_id = new int[n];
                                DateTime[] tu_ngay_luong     = new DateTime[n];

                                for (int i = 0; i < n; i++)
                                {
                                    luong_id[i]          = kvpLuongID[i].Value;
                                    ma_nv[i]             = lstMaNV[i].ToString();
                                    ngach_bac_heso_id[i] = kvpBacMoi[i].Value;
                                    tu_ngay_luong[i]     = kvpNgayHuongMoi[i].Value;
                                }

                                #endregion



                                #region Get thong tin QD

                                string ma_qd  = thongTinQuyetDinh1.txt_MaQD.Text;
                                string ten_qd = thongTinQuyetDinh1.txt_TenQD.Text;
                                string mo_ta  = thongTinQuyetDinh1.rTB_MoTa.Text;

                                int      loai_qd_id = Convert.ToInt32(thongTinQuyetDinh1.comB_Loai.SelectedValue);
                                DateTime tu_ngay_qd = thongTinQuyetDinh1.dTP_NgayHieuLuc.Value;

                                DateTime den_ngay_qd;
                                if (thongTinQuyetDinh1.dTP_NgayHetHan.Checked)
                                {
                                    den_ngay_qd = thongTinQuyetDinh1.dTP_NgayHetHan.Value;
                                }
                                else
                                {
                                    den_ngay_qd = Convert.ToDateTime("01/01/1901").Date;
                                }

                                DateTime ngay_ky = thongTinQuyetDinh1.dTP_NgayKy.Value;

                                #endregion

                                oTinhLuong.Update_ChuyenNgachNhanh(ma_nv, luong_id, tu_ngay_luong, ngach_bac_heso_id
                                                                   , ma_qd, ten_qd, loai_qd_id, tu_ngay_qd, den_ngay_qd, ngay_ky, mo_ta);



                                if (oFile.Path.Count > 0)
                                {
                                    UploadFile();
                                }
                                else
                                {
                                    ResetAll();
                                }



                                MessageBox.Show("Lưu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Lưu không thành công, xin vui lòng thử lại sau.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Có thông tin ngạch chưa được thay đổi, xin vui lòng kiểm tra lại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("Thông tin mã / tên quyết định không được để trống.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Có thông tin lương ngạch chưa được lưu, xin vui lòng kiểm tra lại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }