private void Get_Contract()
        {
            Class.DanhMuc_HopDong dmhd = new Class.DanhMuc_HopDong();
            DataTable             dthd = dmhd.CT_CONTRACT_GetList();

            gridItem.DataSource = dthd;
        }
        private void call_info(string code)
        {
            Class.DanhMuc_HopDong hd = new Class.DanhMuc_HopDong();
            DataTable             dt = hd.CT_CONTRACT_Get(code);

            txtSigner.Text            = dt.Rows[0]["Signer"].ToString();
            txtSignerNationality.Text = dt.Rows[0]["SignerNationality"].ToString();
            txtSignerPosition.Text    = dt.Rows[0]["SignerPosition"].ToString();
            txtCompany.Text           = dt.Rows[0]["Company"].ToString();
            txtAddress.Text           = dt.Rows[0]["Address"].ToString();
            txtTel.Text               = dt.Rows[0]["Tel"].ToString();
            checkIsCurrent.Checked    = (bool)dt.Rows[0]["IsCurrent"];
            txtEmployeeCode.EditValue = dt.Rows[0]["EmployeeCode"].ToString();

            //tab thong tin hop dong
            if (dt.Rows[0]["SecondAllowance"].ToString().Length > 0)
            {
                _textAll = dt.Rows[0]["SecondAllowance"].ToString();
            }
            else
            {
                _textAll = "0";
            }

            txtContractCode.Text  = dt.Rows[0]["ContractCode"].ToString();
            txtContractTime.Text  = dt.Rows[0]["ContractTime"].ToString();
            txtContractType.Text  = dt.Rows[0]["ContractType"].ToString();
            txtContractYear.Text  = dt.Rows[0]["ContractYear"].ToString();
            dateSignDate.DateTime = (DateTime)dt.Rows[0]["SignDate"];
            dateFromDate.DateTime = (DateTime)dt.Rows[0]["FromDate"];
            if (dt.Rows[0]["ToDate"] != DBNull.Value)
            {
                dateToDate.DateTime = (DateTime)dt.Rows[0]["ToDate"];
            }
            txtBasicSalary.Value  = (decimal)dt.Rows[0]["BasicSalary"];
            txtPayForm.Text       = dt.Rows[0]["PayForm"].ToString();
            txtPayDate.Value      = (int)dt.Rows[0]["PayDate"];
            txtAllowance.Text     = dt.Rows[0]["Allowance"].ToString();
            txtTestAllowance.Text = dt.Rows[0]["SecondAllowance"].ToString();
            txtRate.Text          = dt.Rows[0]["Rate"].ToString();
            txtInsurance.Text     = dt.Rows[0]["Insurance"].ToString();
            txtWorkTime.Text      = dt.Rows[0]["WorkTime"].ToString();
            txtSubject.Text       = dt.Rows[0]["Subject"].ToString();
            txtDescription.Text   = dt.Rows[0]["Description"].ToString();
        }
        private void btnPrint_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            int SelectedRow = gridItemDetail.FocusedRowHandle;

            if (SelectedRow >= 0)
            {
                int waitIndex = 0;
                Waiting.ShowWaitForm();
                DataRow drow             = gridItemDetail.GetDataRow(SelectedRow);
                string  _value           = drow["ContractCode"].ToString();
                Class.DanhMuc_HopDong hd = new Class.DanhMuc_HopDong();
                hd.ContractCode = _value;
                DataTable dt = hd.CT_CONTRACT_GetPrintByCode();
                if (_value.IndexOf("HDTV") > 0)
                {
                    // Reports.reportHoDongThuViec rp = new Reports.reportHoDongThuViec();
                    // rp.DataSource = dt;
                    // rp.ShowDesigner();
                    // rp.ShowPreviewDialog();
                }
                else
                {
                    Reports.reportHopDongLaoDong report = new Reports.reportHopDongLaoDong(dt);
                    report.DataSource = dt;
                    Waiting.CloseWaitForm();
                    waitIndex = 1;
                    report.ShowPreviewDialog();


                    report.ShowDesigner();
                    Class.S_Log.Insert("Hợp đồng", "Xem trang In Hợp đồng lao động: " + _value);
                }
                if (waitIndex != 1)
                {
                    Waiting.CloseWaitForm();
                }
            }
        }
 private void Update_hopDong()
 {
     Class.DanhMuc_HopDong dmhd = new Class.DanhMuc_HopDong();
     dmhd.ContractCode      = txtContractCode.Text;
     dmhd.EmployeeCode      = txtEmployeeCode.Text;
     dmhd.ContractType      = txtContractType.Text;
     dmhd.ContractTime      = txtContractTime.Text;
     dmhd.ContractYear      = int.Parse(txtContractYear.Text);
     dmhd.SignDate          = dateSignDate.DateTime;
     dmhd.FromDate          = dateFromDate.DateTime;
     dmhd.ToDate            = dateToDate.DateTime;
     dmhd.BasicSalary       = txtBasicSalary.Value;
     dmhd.PayForm           = txtPayForm.Text;
     dmhd.PayDate           = int.Parse(txtPayDate.Text);
     dmhd.Allowance         = txtAllowance.Text;
     dmhd.SecondAllowance   = txtTestAllowance.Text;
     dmhd.Rate              = int.Parse(txtRate.Text);
     dmhd.Insurance         = txtInsurance.Text;
     dmhd.WorkTime          = txtWorkTime.Text;
     dmhd.Signer            = txtSigner.Text;
     dmhd.SignerPosition    = txtSignerPosition.Text;
     dmhd.SignerNationality = txtSignerNationality.Text;
     dmhd.Company           = txtCompany.Text;
     dmhd.Address           = txtAddress.Text;
     dmhd.Tel         = txtTel.Text;
     dmhd.Subject     = txtSubject.Text;
     dmhd.Description = txtDescription.Text;
     dmhd.IsCurrent   = checkIsCurrent.Checked;
     if (dmhd.Insert())
     {
         Class.App.SaveSuccessfully();
     }
     else
     {
         Class.App.SaveNotSuccessfully();
     }
 }
Пример #5
0
        //string template_grid = Application.StartupPath + @"\Templates\Templates_Menu.xml";

        private void btnDangNhap_ItemClick(object sender, ItemClickEventArgs e)
        {
            frmDangNhap frm = new frmDangNhap();

            frm.Owner = this;
            frm.ShowDialog();
            if (_taiKhoan != "")
            {
                Waiting.ShowWaitForm();
                Waiting.SetWaitFormDescription("Đang tải thông tin tài khoản..");
                Permission_Show_Menu(_taiKhoan);
                //hien thi btndoimatkhau
                btnDoiMatKhau.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
                // goi chuc nang thong bao
                this.btnThongBao.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
                Class.RegistryWriter rg = new Class.RegistryWriter();
                lblFullname.Caption = "Đang sử dụng: " + _taiKhoan + "  | Thời gian: " + DateTime.Now.ToString("dd/MM/yyyy h:m tt") + "   |  Máy chủ: " + rg.valuekey("server");
                sv_host             = rg.valuekey("server");

                // goi thong tin de luu Log phan mem
                Class.S_Log.Call_PcInfo();
                Class.S_Log.UserName = _taiKhoan.ToLower();
                ribbon.SelectedPage  = Menu_Hrm;
                Class.S_Log.Insert("Hệ thống", "Đăng nhập");
                Class.App.client_User = _taiKhoan;
                if (rg.valuekey("alert") == "Blue")
                {
                    btnThongBao.Enabled = true;
                }
                else if (rg.valuekey("alert") == "1")
                {
                    btnThongBao.Enabled = true;
                    Class.ThongKe tk = new Class.ThongKe();
                    DataTable     dt = tk.CT_EMPLOYEE_GetListBirthday();
                    if (dt.Rows.Count > 0)
                    {
                        dt.Columns.Add("Day", Type.GetType("System.String"));
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            string txt = ((DateTime)dt.Rows[i]["BirthDay"]).Day.ToString();
                            if (txt.Length == 1)
                            {
                                txt = "0" + txt;
                            }
                            dt.Rows[i]["Day"] = txt;
                        }
                        DataView dv = dt.DefaultView;
                        dv.Sort = "Day ASC";
                        dt      = dv.ToTable();

                        // xuat thong bao sinh nhat sap den
                        string tb = "";
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            tb += (i + 1).ToString() + ". " + dt.Rows[i]["FirstName"].ToString() + " " + dt.Rows[i]["LastName"].ToString() + ": <i>" + ((DateTime)dt.Rows[i]["Birthday"]).ToString("dd/MM/yyyy") + "</i>\n";
                        }
                        alertControl.Show(this, "Danh sách sắp đến ngày sinh nhật:", tb);
                        //-------------
                        // xuat danh sach sap phai ky lai hop dong
                        Class.DanhMuc_HopDong hd   = new Class.DanhMuc_HopDong();
                        DataTable             dthd = hd.CT_CONTRACT_GetListJustExpiration();
                        if (dthd.Rows.Count > 0)
                        {
                            DataView _dv = new DataView();
                            _dv      = dthd.DefaultView;
                            _dv.Sort = "ToDate ASC";


                            string tb2 = "";
                            for (int i = 0; i < _dv.Count; i++)
                            {
                                tb2 += (i + 1).ToString() + ". " + _dv[i]["FirstName"].ToString() + " " + _dv[i]["LastName"].ToString() + " -<i> " + ((DateTime)_dv[i]["ToDate"]).ToString("dd/MM/yyyy") + "</i>\n";;
                            }
                            alertControl.Show(this, "Danh sách sắp ký lại hợp đồng :", tb2);
                        }
                        ////-----------------=================
                        if (File.Exists(@"media/" + Class.App.media))
                        {
                            SoundPlayer simpleSound = new SoundPlayer(@"media/" + Class.App.media);
                            simpleSound.Play();
                        }
                    }
                }
                else
                {
                    btnThongBao.Enabled = false;
                }

                Waiting.CloseWaitForm();
            }
        }
        private void xulyTaoCodeHopdong()
        {
            if (btnUpdate.Enabled == true)
            {
                if (txtFullName.Text != "[Họ và tên nhân viên]")
                {
                    Class.DanhMuc_HopDong hd = new Class.DanhMuc_HopDong();
                    //  Class.NhanVien_HopDong hd = new Class.NhanVien_HopDong();
                    hd.ContractYear = int.Parse(txtContractYear.Text);
                    // hd.ContractType = txtContractType.Text;
                    DataTable dt = hd.CT_CONTRACT_GetByYear();
                    hd.EmployeeCode = txtEmployeeCode.EditValue.ToString();
                    DataTable dthdbynv = hd.CT_CONTRACT_GetByEmployee();

                    if (dt.Rows.Count > 0)
                    {
                        string   _idCheck;
                        string[] cat;
                        int      next_ID  = 0;
                        int      next_ID2 = 0;
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            _idCheck = dt.Rows[i]["ContractCode"].ToString();
                            cat      = _idCheck.Split('-');
                            next_ID2 = int.Parse(cat.GetValue(0).ToString());
                            if ((next_ID2 - next_ID) > 1)
                            {
                                break;
                            }
                            next_ID = int.Parse(cat.GetValue(0).ToString());
                        }
                        //string _idContract = dt.Rows[dt.Rows.Count - 1]["ContractCode"].ToString();
                        //cat = _idContract.Split('-');
                        // next_ID = int.Parse(cat.GetValue(0).ToString()) + 1;
                        next_ID++;
                        if (next_ID.ToString().Length == 1)
                        {
                            txtContractCode.Text = "000" + next_ID.ToString() + "-" + txtContractYear.Text;
                        }
                        if (next_ID.ToString().Length == 2)
                        {
                            txtContractCode.Text = "00" + next_ID.ToString() + "-" + txtContractYear.Text;
                        }
                        if (next_ID.ToString().Length == 3)
                        {
                            txtContractCode.Text = "0" + next_ID.ToString() + "-" + txtContractYear.Text;
                        }
                        if (next_ID.ToString().Length == 4)
                        {
                            txtContractCode.Text = next_ID.ToString() + "-" + txtContractYear.Text;
                        }
                    }
                    else
                    {
                        txtContractCode.Text = "0001-" + txtContractYear.Text;
                    }
                    // kiem tra ky hop dong truc tiep ko co thu viec
                    int solanHD = 1;
                    for (int i = 0; i < dthdbynv.Rows.Count; i++)
                    {
                        string maHD = dthdbynv.Rows[i]["ContractCode"].ToString();
                        if (maHD.Contains("HDTV"))
                        {
                            solanHD = dthdbynv.Rows.Count;
                            break;
                        }
                        if (maHD.Contains("HDLD"))
                        {
                            solanHD++;
                        }
                    }
                    switch (txtContractType.Text)
                    {
                    case "Hợp đồng xác định thời hạn":
                        txtContractCode.Text = txtContractCode.Text + "/HDLD/Lan" + solanHD;
                        break;

                    case "Hợp đồng không xác định thời hạn":
                        txtContractCode.Text = txtContractCode.Text + "/HDLD/KXDTH-Lan" + solanHD;
                        break;

                    case "Hợp đồng thử việc":
                        txtContractCode.Text = txtContractCode.Text + "/HDTV";
                        break;

                    case "Hợp đồng học việc":
                        txtContractCode.Text = txtContractCode.Text + "/HDHV";
                        break;
                    }

                    if (dthdbynv.Rows.Count > 0)
                    {
                        if (dthdbynv.Rows[dthdbynv.Rows.Count - 1]["ToDate"] != DBNull.Value)
                        {
                            DateTime _dateNgaykt     = (DateTime)dthdbynv.Rows[dthdbynv.Rows.Count - 1]["ToDate"];
                            DateTime _dateNgayKyTiep = _dateNgaykt.AddDays(1);
                            dateFromDate.DateTime = _dateNgayKyTiep;
                            dateSignDate.DateTime = _dateNgayKyTiep;
                            dateFromDate_Validated(null, null);
                        }
                    }
                    else
                    {
                        // la HDTV se lay ngay tu ngay bat dau lam viec
                        dateFromDate.DateTime = DateBegin;
                        dateSignDate.DateTime = DateBegin;
                        dateFromDate_Validated(null, null);
                    }
                }
                else
                {
                    MessageBox.Show("Vui Lòng chọn nhân viên ký hợp đồng trước");
                    TabControl.SelectedTabPage = TabPage1;
                }
            }

            // tam thoi han che khong cho lam lap 4 hop dong lao dong
            if (txtContractCode.Text.Contains("Lan4"))
            {
                MessageBox.Show("Hợp đồng Lao động chỉ chấp nhận nhỏ hơn 4 lần, Vui lòng kiểm tra lại hoặc liên hệ Người Quản Trị", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }