Пример #1
0
        bool loadDB()
        {
            try
            {
                var df = Properties.Settings.Default;
                MssBox.iWaitForm(splashScreenManager1);
                splashScreenManager1.SetWaitFormDescription(string.Format("Connecting {0}", df.Host));

                string conString = new System.Data.SqlClient.SqlConnectionStringBuilder()
                {
                    DataSource          = df.Host,
                    InitialCatalog      = df.DBName,
                    UserID              = df.Username,
                    Password            = OneSecurity.Decryption(df.Password),
                    PersistSecurityInfo = true,
                }.ConnectionString;

                using (var db = new CDMSDBDataContext(conString))
                {
                    db.Connection.Open();
                    splashScreenManager1.SetWaitFormDescription(string.Format("Connected {0}", df.Host));
                }
                Program.conStr = conString;
                MssBox.iWaitForm(splashScreenManager1);
                return(true);
            }
            catch (Exception ex)
            {
                MssBox.iWaitForm(splashScreenManager1);
                MssBox.Error(ex);
                return(false);
            }
        }
        private void ShowHistD()
        {
            barDel.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            New = true;
            txtFactor.Focus();
            txtFactor.Text = null;
            txtDevice.Text = null;
            txtRem.Text    = null;

            var db = new CDMSDBDataContext(Program.conStr);

            historyWorkDetailBindingSource.DataSource = new HistoryWork_Detail();

            var HtwName = (from x in db.HistoryWorks
                           where x.Htw_Key == HtwID &&
                           x.Htw_Status == 1 &&
                           x.Htw_Del == 0
                           select x.Htw_CompanyName).FirstOrDefault().ToString();

            lbName.Text = HtwName;

            var HistD = (from x in db.HistoryWork_Details
                         where x.Htw_Key == HtwID &&
                         x.Htwd_Status == 1 &&
                         x.Htwd_Del == 0
                         select x).ToList();

            historyWorkDetailBindingSource.DataSource = HistD;
        }
        private void barDel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                if (MssBox.QuestionYesNo("คุณค้องการลบข้อมูลประสบการณ์ทำงาน ใช่ หรือ ไม่ ?") == DialogResult.Yes)
                {
                    var HistDCur = (HistoryWork_Detail)historyWorkDetailBindingSource.Current;

                    var db = new CDMSDBDataContext(Program.conStr);

                    var DelHistD = (from x in db.HistoryWork_Details
                                    where x.Htwd_Key == HistDCur.Htwd_Key &&
                                    x.Htwd_Status == 1 &&
                                    x.Htwd_Del == 0
                                    select x).FirstOrDefault();

                    if (DelHistD != null)
                    {
                        DelHistD.Htwd_Del = 1;
                    }

                    db.SubmitChanges();

                    ShowHistD();
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                MssBox.Error(ex.Message);
            }
        }
Пример #4
0
        private void ShowExp()
        {
            txtComName.Focus();

            barDel.Visibility     = DevExpress.XtraBars.BarItemVisibility.Never;
            btnOpenFactor.Visible = false;

            New                    = true;
            txtComName.Text        = null;
            memoRem.Text           = null;
            txtDept.Text           = null;
            txtComType.Text        = null;
            txtWorkType.Text       = null;
            StartWorkDate.DateTime = GetMasterDataClass.GetDateServer();
            StopWorkDate.DateTime  = GetMasterDataClass.GetDateServer();

            var db = new CDMSDBDataContext(Program.conStr);

            historyWorkBindingSource.DataSource = new HistoryWork();

            var Exp = (from x in db.HistoryWorks
                       where x.Emp_Key == EmpID &&
                       x.Htw_Status == 1 &&
                       x.Htw_Del == 0
                       select x).ToList();

            historyWorkBindingSource.DataSource = Exp;
        }
Пример #5
0
        private void LookSec_EditValueChanged(object sender, EventArgs e)
        {
            var db = new CDMSDBDataContext(Program.conStr);

            deptBindingSource.DataSource = db.Depts.ToList();

            deptBindingSource.DataSource = (from x in db.Depts where x.Sec_Key == (int)LookSec.EditValue select x).ToList();
        }
Пример #6
0
        private void LookAddIDDistrict_EditValueChanged(object sender, EventArgs e)
        {
            var db = new CDMSDBDataContext(Program.conStr);

            txtAddIDZipCode.Text = (from i in db.ThailandDistricts where i.Dis_Key == Convert.ToInt32(LookAddIDDistrict.EditValue) select i.Dis_Zip).FirstOrDefault().ToString();

            LookAddIDAmphur.EditValue = (from i in db.ThailandDistricts where i.Dis_Key == Convert.ToInt32(LookAddIDDistrict.EditValue) select i.Amp_Key).FirstOrDefault();

            LookAddIDProvince.EditValue = (from i in db.ThailandAmphurs where i.Amp_Key == Convert.ToInt32(LookAddIDAmphur.EditValue) select i.Prov_Key).FirstOrDefault();
        }
        private void barSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                if (MssBox.QuestionYesNo("คุณค้องการลบข้อมูลประสบการณ์ทำงาน ใช่ หรือ ไม่ ?") == DialogResult.Yes)
                {
                    var db = new CDMSDBDataContext(Program.conStr);

                    if (New == true)
                    {
                        var HtwD = new HistoryWork_Detail();

                        HtwD.Htw_Key       = HtwID;
                        HtwD.Htwd_Factor   = txtFactor.Text;
                        HtwD.Htwd_Device   = txtDevice.Text;
                        HtwD.Htwd_Rem      = txtRem.Text;
                        HtwD.Htwd_CreateBy = 1;
                        HtwD.Htwd_Status   = 1;
                        HtwD.Htwd_Del      = 0;

                        db.HistoryWork_Details.InsertOnSubmit(HtwD);
                        db.SubmitChanges();
                    }
                    else
                    {
                        var HistDCur = (HistoryWork_Detail)historyWorkDetailBindingSource.Current;

                        var UpHtwD = (from x in db.HistoryWork_Details
                                      where x.Htw_Key == HistDCur.Htw_Key &&
                                      x.Htwd_Status == 1 &&
                                      x.Htwd_Del == 0
                                      select x).FirstOrDefault();

                        UpHtwD.Htwd_Factor   = txtFactor.Text;
                        UpHtwD.Htwd_Device   = txtDevice.Text;
                        UpHtwD.Htwd_Rem      = txtRem.Text;
                        UpHtwD.Htwd_ModifyBy = 1;

                        db.SubmitChanges();
                    }
                    ShowHistD();
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                MssBox.Error(ex.Message);
            }
        }
Пример #8
0
        private void ShowEmployee()
        {
            employeeBindingSource.DataSource = new Employee();

            var db = new CDMSDBDataContext(Program.conStr);

            var ShowEmp = (from x in db.Employees
                           where x.Emp_Status == 1 &&
                           x.Emp_Del == 0
                           select x).ToList();

            employeeBindingSource.DataSource = ShowEmp;
        }
        private void EmployeeHistorySicknessForm_Shown(object sender, EventArgs e)
        {
            try
            {
                var db          = new CDMSDBDataContext(Program.conStr);
                var get_hissink = (from i in db.HistorySicknesses where i.Emp_Key == this.emp_id select i).FirstOrDefault();

                if (get_hissink != null)
                {
                    //Open
                    historySicknessSickInjuryBindingSource.DataSource = get_hissink.HistorySickness_SickInjuries.ToList();

                    radioGroupDiseaseChronic2.EditValue = get_hissink.Hts_DiseaseChronic;
                    tbDiseaseChronic2.EditValue         = get_hissink.Hts_DiseaseChronic_Specify;

                    radioGroupSergery3.EditValue = get_hissink.Hts_Sergery;
                    tbSergery3.EditValue         = get_hissink.Hts_Sergery_Specify;

                    radioGroupImmunity4.EditValue = get_hissink.Hts_Immunity;
                    tbImmunity4.EditValue         = get_hissink.Hts_Immunity_Specify;

                    radioGroupFamily5.EditValue = get_hissink.Hts_Family;
                    historySicknessFamilyBindingSource.DataSource = get_hissink.HistorySickness_Families.ToList();

                    radioGroupMedicine6.EditValue = get_hissink.Hts_Medicine;
                    tbMedicine6.EditValue         = get_hissink.Hts_Medicine_Specify;

                    radioGroupMedicineAllergic7.EditValue = get_hissink.Hts_MedicineAllergic;
                    tbMedicineAllergic7.EditValue         = get_hissink.Hts_MedicineAllergic_Specify;

                    radioGroupSmoking8.EditValue = get_hissink.Hts_Smoking;
                    tbPresentCount8.EditValue    = get_hissink.Hts_Smoking_PresentCount;
                    tbQuitMonth8.EditValue       = get_hissink.Hts_Smoking_QuitMonth;
                    tbQuitYear8.EditValue        = get_hissink.Hts_Smoking_QuitYear;
                    tbBeforeQuitCount8.EditValue = get_hissink.Hts_Somking_BeforeQuitCount;

                    radioGroupDrinking9.EditValue = get_hissink.Hts_Drinking;
                    tbQuitMonth9.EditValue        = get_hissink.Hts_Drinking_QuitMonth;
                    tbQuitYear9.EditValue         = get_hissink.Hts_Drinking_QuitYear;

                    radioGroupAddictive10.EditValue = get_hissink.Hts_Addictive;
                    tbAddictive10.EditValue         = get_hissink.Hts_Addictive_Specify;

                    tbOthers11.EditValue = get_hissink.Hts_Others;
                }
            }
            catch (Exception ex)
            {
                MssBox.Error(ex);
            }
        }
Пример #10
0
 bool MessageConnect(string conStr)
 {
     try
     {
         var condb = new CDMSDBDataContext(conStr);
         condb.Connection.Open();
         lbStatus.Text      = "Connection Successful..";
         lbStatus.ForeColor = Color.Green;
         return(true);
     }
     catch (Exception)
     {
         lbStatus.Text      = "Connection failed..";
         lbStatus.ForeColor = Color.Red;
         return(false);
     }
 }
Пример #11
0
        private void ShowDataEmployee()
        {
            var db = new CDMSDBDataContext(Program.conStr);

            var Emp = (from x in db.Employees
                       where x.Emp_Key == EmpID
                       select x).FirstOrDefault();

            txtIDCard.Text = Emp.IDCard;
            //Emp.EmployeeID
            txtFName.Text             = Emp.Emp_Fname;
            txtSName.Text             = Emp.Emp_Surname;
            lbAge.Text                = Emp.Age.ToString();
            dateOfBirth.DateTime      = Emp.Birthday.Value;
            dateOfWork.DateTime       = Emp.StartDayWork.Value;
            LookTitle.EditValue       = Emp.Title_Key;
            radioGender.SelectedIndex = (Emp.Gender_Key == 1) ? 0 : 1;
            //if (Emp.Gender_Key == 1){radioGender.SelectedIndex = 0;}else{radioGender.SelectedIndex = 1;}
            LookDept.EditValue = Emp.Dept_Key;
            LookSec.EditValue  = Emp.Sec_Key;
            LookBrn.EditValue  = Emp.Brn_Key;
            LookFac.EditValue  = Emp.Fact_Key;
            memoREM.Text       = Emp.Emp_REM.ToString();

            txtAddIDNo.Text             = Emp.AddressByIDCard.AddrIDCard_Address_NO;
            txtAddIDMoo.Text            = Emp.AddressByIDCard.AddrIDCard_Address_Moo;
            txtAddIDSoi.Text            = Emp.AddressByIDCard.AddrIDCard_Address_Soi;
            txtAddIDStreet.Text         = Emp.AddressByIDCard.AddrIDCard_Address_Street;
            LookAddIDDistrict.EditValue = Emp.AddressByIDCard.AddrIDCard_Address_District;
            txtAddIDTel.Text            = Emp.AddressByIDCard.AddrIDCard_Telelphone;

            txtAddConNo.Text             = Emp.AddressByContact.AddrCont_Address_NO;
            txtAddConMoo.Text            = Emp.AddressByContact.AddrCont_Address_Moo;
            txtAddConSoi.Text            = Emp.AddressByContact.AddrCont_Address_Soi;
            txtAddConStreet.Text         = Emp.AddressByContact.AddrCont_Address_Street;
            LookAddConDistrict.EditValue = Emp.AddressByContact.AddrCont_Address_District;
            txtAddConTel.Text            = Emp.AddressByContact.AddrCont_Telelphone;

            txtAddFacName.Text           = Emp.AddressByCompany.AddrCom_Name;
            txtAddFacNo.Text             = Emp.AddressByCompany.AddrCom_Address_NO;
            txtAddFacMoo.Text            = Emp.AddressByCompany.AddrCom_Address_Moo;
            txtAddFacSoi.Text            = Emp.AddressByCompany.AddrCom_Address_Soi;
            txtAddFacStreet.Text         = Emp.AddressByCompany.AddrCom_Address_Street;
            LookAddFacDistrict.EditValue = Emp.AddressByCompany.AddrCom_Address_District;
            txtAddFacTel.Text            = Emp.AddressByCompany.AddrCom_Telelphone;
        }
Пример #12
0
        private void bbiDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                if (MssBox.QuestionYesNo("คุณค้องการลบข้อมูลพนักงาน ใช่ หรือ ไม่ ?") == DialogResult.Yes)
                {
                    MssBox.iWaitForm(splashScreenManager1);

                    var Emp = (Employee)employeeBindingSource.Current;

                    var db = new CDMSDBDataContext(Program.conStr);

                    var DelEmp = (from x in db.Employees
                                  where x.Emp_Key == Emp.Emp_Key
                                  select x).FirstOrDefault();

                    if (DelEmp != null)
                    {
                        DelEmp.Emp_Del = 1;
                        db.SubmitChanges();
                    }

                    ShowEmployee();

                    MssBox.iWaitForm(splashScreenManager1);
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                MssBox.iWaitForm(splashScreenManager1);
                MssBox.Error(ex.Message);
            }
        }
Пример #13
0
        private void EmployeeManageForm_Load(object sender, EventArgs e)
        {
            var db = new CDMSDBDataContext(Program.conStr);

            factoryBindingSource.DataSource       = db.Factories.ToList();
            branchBindingSource.DataSource        = db.Branches.ToList();
            sectionBindingSource.DataSource       = db.Sections.ToList();
            deptBindingSource.DataSource          = db.Depts.ToList();
            employeeTitleBindingSource.DataSource = db.EmployeeTitles.ToList();

            thailandDistrictBindingSource.DataSource = db.ThailandDistricts.ToList();
            thailandAmphurBindingSource.DataSource   = db.ThailandAmphurs.ToList();
            thailandProvinceBindingSource.DataSource = db.ThailandProvinces.ToList();

            if (EmpID != 0)
            {
                ShowDataEmployee();
                btnOpenExp.Visible = true;
            }
            else
            {
                btnOpenExp.Visible = false;
            }
        }
Пример #14
0
        private void btnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                if (MssBox.QuestionYesNo("คุณต้องการบันทึกข้อมูลพนักงาน ใช่ หรือ ไม่ ?") == DialogResult.Yes)
                {
                    MssBox.iWaitForm(splashScreenManager1);

                    var db = new CDMSDBDataContext(Program.conStr);

                    var ChkKey = (from x in db.Employees
                                  where x.Emp_Key == EmpID
                                  select x).FirstOrDefault();

                    if (ChkKey == null)
                    {
                        using (var tran = new System.Transactions.TransactionScope())
                        {
                            var AddID = new AddressByIDCard();
                            AddID.AddrIDCard_Address_NO       = txtAddIDNo.Text;
                            AddID.AddrIDCard_Address_Moo      = txtAddIDMoo.Text;
                            AddID.AddrIDCard_Address_Soi      = txtAddIDSoi.Text;
                            AddID.AddrIDCard_Address_Street   = txtAddIDStreet.Text;
                            AddID.AddrIDCard_Address_District = Convert.ToInt32(LookAddIDDistrict.EditValue);
                            AddID.AddrIDCard_Address_Amphur   = Convert.ToInt32(LookAddIDAmphur.EditValue);
                            AddID.AddrIDCard_Address_Province = Convert.ToInt32(LookAddIDProvince.EditValue);
                            AddID.AddrIDCard_Address_ZipCode  = Convert.ToInt32(txtAddIDZipCode.Text);
                            AddID.AddrIDCard_Telelphone       = txtAddIDTel.Text;
                            AddID.AddrIDCard_Status           = 1;
                            AddID.AddrIDCard_Del = 0;
                            db.AddressByIDCards.InsertOnSubmit(AddID);
                            db.SubmitChanges();

                            var AddCon = new AddressByContact();
                            AddCon.AddrCont_Address_NO       = txtAddConNo.Text;
                            AddCon.AddrCont_Address_Moo      = txtAddConMoo.Text;
                            AddCon.AddrCont_Address_Soi      = txtAddConSoi.Text;
                            AddCon.AddrCont_Address_Street   = txtAddConStreet.Text;
                            AddCon.AddrCont_Address_District = Convert.ToInt32(LookAddConDistrict.EditValue);
                            AddCon.AddrCont_Address_Amphur   = Convert.ToInt32(LookAddConAmphur.EditValue);
                            AddCon.AddrCont_Address_Province = Convert.ToInt32(LookAddConProvince.EditValue);
                            AddCon.AddrCont_Address_ZipCode  = Convert.ToInt32(txtAddConZipCode.Text);
                            AddCon.AddrCont_Telelphone       = txtAddConTel.Text;
                            AddCon.AddrCont_Status           = 1;
                            AddCon.AddrCont_Del = 0;
                            db.AddressByContacts.InsertOnSubmit(AddCon);
                            db.SubmitChanges();

                            var AddFac = new AddressByCompany();
                            AddFac.AddrCom_Name             = txtAddFacName.Text;
                            AddFac.AddrCom_Address_NO       = txtAddFacNo.Text;
                            AddFac.AddrCom_Address_Moo      = txtAddFacMoo.Text;
                            AddFac.AddrCom_Address_Soi      = txtAddFacSoi.Text;
                            AddFac.AddrCom_Address_Street   = txtAddFacStreet.Text;
                            AddFac.AddrCom_Address_District = Convert.ToInt32(LookAddFacDistrict.EditValue);
                            AddFac.AddrCom_Address_Amphur   = Convert.ToInt32(LookAddFacAmphur.EditValue);
                            AddFac.AddrCom_Address_Province = Convert.ToInt32(LookAddFacProvince.EditValue);
                            AddFac.AddrCom_Address_ZipCode  = Convert.ToInt32(txtAddFacZipCode.Text);
                            AddFac.AddrCom_Telelphone       = txtAddFacTel.Text;
                            AddFac.AddrCom_Status           = 1;
                            AddFac.AddrCom_Del = 0;
                            db.AddressByCompanies.InsertOnSubmit(AddFac);
                            db.SubmitChanges();

                            var Emp = new Employee();
                            Emp.Birthday     = dateOfBirth.DateTime.Date;
                            Emp.StartDayWork = dateOfWork.DateTime.Date;
                            Emp.IDCard       = txtIDCard.Text;
                            //Emp.EmployeeID
                            Emp.Emp_Fname      = txtFName.Text;
                            Emp.Emp_Name       = txtFName.Text + "  " + txtSName.Text;
                            Emp.Emp_Surname    = txtSName.Text;
                            Emp.Age            = Convert.ToInt32(lbAge.Text);
                            Emp.Title_Key      = Convert.ToInt32(LookTitle.EditValue);
                            Emp.Gender_Key     = Convert.ToInt32(radioGender.EditValue);
                            Emp.Dept_Key       = Convert.ToInt32(LookDept.EditValue);
                            Emp.Sec_Key        = Convert.ToInt32(LookSec.EditValue);
                            Emp.Brn_Key        = Convert.ToInt32(LookBrn.EditValue);
                            Emp.Fact_Key       = Convert.ToInt32(LookFac.EditValue);
                            Emp.AddrIDCard_Key = AddID.AddrIDCard_Key;
                            Emp.AddrCont_Key   = AddCon.AddrCont_Key;
                            Emp.AddrCom_Key    = AddFac.AddrCom_Key;
                            Emp.Emp_REM        = memoREM.Text;
                            Emp.Emp_Status     = 1;
                            Emp.Emp_Del        = 0;
                            db.Employees.InsertOnSubmit(Emp);
                            db.SubmitChanges();

                            tran.Complete();
                        }
                    }
                    else
                    {
                        using (var tran = new System.Transactions.TransactionScope())
                        {
                            var AddID = (from x in db.AddressByIDCards
                                         where x.AddrIDCard_Key == ChkKey.AddrIDCard_Key
                                         select x).FirstOrDefault();

                            AddID.AddrIDCard_Address_NO       = txtAddIDNo.Text;
                            AddID.AddrIDCard_Address_Moo      = txtAddIDMoo.Text;
                            AddID.AddrIDCard_Address_Soi      = txtAddIDSoi.Text;
                            AddID.AddrIDCard_Address_Street   = txtAddIDStreet.Text;
                            AddID.AddrIDCard_Address_District = Convert.ToInt32(LookAddIDDistrict.EditValue);
                            AddID.AddrIDCard_Address_Amphur   = Convert.ToInt32(LookAddIDAmphur.EditValue);
                            AddID.AddrIDCard_Address_Province = Convert.ToInt32(LookAddIDProvince.EditValue);
                            AddID.AddrIDCard_Address_ZipCode  = Convert.ToInt32(txtAddIDZipCode.Text);
                            AddID.AddrIDCard_Telelphone       = txtAddIDTel.Text;
                            AddID.AddrIDCard_Status           = 1;
                            AddID.AddrIDCard_Del = 0;
                            db.SubmitChanges();

                            var AddCon = (from x in db.AddressByContacts
                                          where x.AddrCont_Key == ChkKey.AddrCont_Key
                                          select x).FirstOrDefault();

                            AddCon.AddrCont_Address_NO       = txtAddConNo.Text;
                            AddCon.AddrCont_Address_Moo      = txtAddConMoo.Text;
                            AddCon.AddrCont_Address_Soi      = txtAddConSoi.Text;
                            AddCon.AddrCont_Address_Street   = txtAddConStreet.Text;
                            AddCon.AddrCont_Address_District = Convert.ToInt32(LookAddConDistrict.EditValue);
                            AddCon.AddrCont_Address_Amphur   = Convert.ToInt32(LookAddConAmphur.EditValue);
                            AddCon.AddrCont_Address_Province = Convert.ToInt32(LookAddConProvince.EditValue);
                            AddCon.AddrCont_Address_ZipCode  = Convert.ToInt32(txtAddConZipCode.Text);
                            AddCon.AddrCont_Telelphone       = txtAddConTel.Text;
                            AddCon.AddrCont_Status           = 1;
                            AddCon.AddrCont_Del = 0;
                            db.SubmitChanges();

                            var AddFac = (from x in db.AddressByCompanies
                                          where x.AddrCom_Key == ChkKey.AddrCom_Key
                                          select x).FirstOrDefault();

                            AddFac.AddrCom_Name             = txtAddFacName.Text;
                            AddFac.AddrCom_Address_NO       = txtAddFacNo.Text;
                            AddFac.AddrCom_Address_Moo      = txtAddFacMoo.Text;
                            AddFac.AddrCom_Address_Soi      = txtAddFacSoi.Text;
                            AddFac.AddrCom_Address_Street   = txtAddFacStreet.Text;
                            AddFac.AddrCom_Address_District = Convert.ToInt32(LookAddFacDistrict.EditValue);
                            AddFac.AddrCom_Address_Amphur   = Convert.ToInt32(LookAddFacAmphur.EditValue);
                            AddFac.AddrCom_Address_Province = Convert.ToInt32(LookAddFacProvince.EditValue);
                            AddFac.AddrCom_Address_ZipCode  = Convert.ToInt32(txtAddFacZipCode.Text);
                            AddFac.AddrCom_Telelphone       = txtAddFacTel.Text;
                            AddFac.AddrCom_Status           = 1;
                            AddFac.AddrCom_Del = 0;
                            db.SubmitChanges();

                            var Emp = (from x in db.Employees
                                       where x.Emp_Key == ChkKey.Emp_Key
                                       select x).FirstOrDefault();

                            Emp.Birthday     = dateOfBirth.DateTime.Date;
                            Emp.StartDayWork = dateOfWork.DateTime.Date;
                            Emp.IDCard       = txtIDCard.Text;
                            //Emp.EmployeeID
                            Emp.Emp_Fname      = txtFName.Text;
                            Emp.Emp_Name       = txtFName.Text + "  " + txtSName.Text;
                            Emp.Emp_Surname    = txtSName.Text;
                            Emp.Age            = Convert.ToInt32(lbAge.Text);
                            Emp.Title_Key      = Convert.ToInt32(LookTitle.EditValue);
                            Emp.Gender_Key     = Convert.ToInt32(radioGender.EditValue);
                            Emp.Dept_Key       = Convert.ToInt32(LookDept.EditValue);
                            Emp.Sec_Key        = Convert.ToInt32(LookSec.EditValue);
                            Emp.Brn_Key        = Convert.ToInt32(LookBrn.EditValue);
                            Emp.Fact_Key       = Convert.ToInt32(LookFac.EditValue);
                            Emp.AddrIDCard_Key = AddID.AddrIDCard_Key;
                            Emp.AddrCont_Key   = AddCon.AddrCont_Key;
                            Emp.AddrCom_Key    = AddFac.AddrCom_Key;
                            Emp.Emp_REM        = memoREM.Text;
                            Emp.Emp_Status     = 1;
                            Emp.Emp_Del        = 0;
                            db.SubmitChanges();

                            tran.Complete();
                        }
                    }
                    MssBox.iWaitForm(splashScreenManager1);
                    MssBox.Success("คุณได้ทำการบันทึกข้อมูลพนักงานเรียบร้อยแล้ว");
                    this.Close();
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                MssBox.iWaitForm(splashScreenManager1);
                MssBox.Error(ex.Message);
            }
        }
Пример #15
0
        private void barSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                if (MssBox.QuestionYesNo("คุณค้องการลบข้อมูลประสบการณ์ทำงาน ใช่ หรือ ไม่ ?") == DialogResult.Yes)
                {
                    if (New == true)
                    {
                        var db = new CDMSDBDataContext(Program.conStr);

                        var SaveExp = new HistoryWork();

                        SaveExp.Htw_CompanyName      = txtComName.Text;
                        SaveExp.Htw_CompanyDept      = txtDept.Text;
                        SaveExp.Htw_Category         = txtComType.Text;
                        SaveExp.Htw_JobDescription   = txtWorkType.Text;
                        SaveExp.Htw_StartDateForWork = StartWorkDate.DateTime;
                        SaveExp.Htw_EndDateForWork   = StopWorkDate.DateTime;
                        SaveExp.Htw_Rem    = memoRem.Text;
                        SaveExp.Emp_Key    = EmpID;
                        SaveExp.Htw_Status = 1;
                        SaveExp.Htw_Del    = 0;

                        db.HistoryWorks.InsertOnSubmit(SaveExp);
                        db.SubmitChanges();
                    }
                    else
                    {
                        var db = new CDMSDBDataContext(Program.conStr);

                        var ExpCur = (HistoryWork)historyWorkBindingSource.Current;

                        var UpdateExp = (from x in db.HistoryWorks
                                         where x.Htw_Key == ExpCur.Htw_Key &&
                                         x.Htw_Status == 1 &&
                                         x.Htw_Del == 0
                                         select x).FirstOrDefault();

                        UpdateExp.Htw_CompanyName      = txtComName.Text;
                        UpdateExp.Htw_CompanyDept      = txtDept.Text;
                        UpdateExp.Htw_Category         = txtComType.Text;
                        UpdateExp.Htw_JobDescription   = txtWorkType.Text;
                        UpdateExp.Htw_StartDateForWork = StartWorkDate.DateTime;
                        UpdateExp.Htw_EndDateForWork   = StopWorkDate.DateTime;
                        UpdateExp.Htw_Rem = memoRem.Text;

                        db.SubmitChanges();
                    }

                    ShowExp();
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                MssBox.Error(ex.Message);
            }
        }
Пример #16
0
        public static DateTime GetDateServer()
        {
            var db = new CDMSDBDataContext(Program.conStr);

            return(db.ExecuteQuery <DateTime>("SELECT GETDATE()").FirstOrDefault());
        }
        private void btSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                if (!dxValidationProvider10.Validate())
                {
                    return;
                }

                if (!CheckBefore())
                {
                    return;
                }
                var db = new CDMSDBDataContext(Program.conStr);
                gv_sicklnjury.CloseEditor();
                gvSickness_Family.CloseEditor();
                var date_sv = MssBox.GetDateServer(db);

                #region Save_sickness_and_detail and Update

                MssBox.iWaitForm(splashScreenManager1);
                #region เตียมข้อมูล
                var getdatafor_sickness = (from i in db.HistorySicknesses where i.Emp_Key == this.emp_id select i).FirstOrDefault();

                var      sickn_ls      = (List <HistorySickness_SickInjury>)historySicknessSickInjuryBindingSource.DataSource;
                string[] for_del_sickn = { "0" };
                if (sickn_ls.Count > 0)
                {
                    string[] not_del_sickn = sickn_ls.Select(x => x.Htss_Key.ToString()).ToArray();
                    for_del_sickn = (from i in db.HistorySickness_SickInjuries where (i.Hts_Key == getdatafor_sickness.Hts_Key && !not_del_sickn.Contains(i.Htss_Key.ToString())) select i.Htss_Key.ToString()).ToArray();
                }

                var      family_ls   = (List <HistorySickness_Family>)historySicknessFamilyBindingSource.DataSource;
                string[] for_del_fam = { "0" };;
                if (family_ls.Count > 0)
                {
                    string[] not_del_fam = family_ls.Select(x => x.Htsf_Key.ToString()).ToArray();
                    for_del_fam = (from i in db.HistorySickness_Families where (i.Hts_Key == getdatafor_sickness.Hts_Key && !not_del_fam.Contains(i.Htsf_Key.ToString())) select i.Htsf_Key.ToString()).ToArray();
                }
                #endregion

                using (var ts = new System.Transactions.TransactionScope())
                {
                    int EHS_id = 0;
                    if (getdatafor_sickness == null)
                    {
                        //Save
                        var EHS = new HistorySickness();
                        EHS.Hts_DiseaseChronic         = Convert.ToBoolean(radioGroupDiseaseChronic2.EditValue);
                        EHS.Hts_DiseaseChronic_Specify = tbDiseaseChronic2.Text;
                        EHS.Hts_Sergery                  = Convert.ToBoolean(radioGroupSergery3.EditValue);
                        EHS.Hts_Sergery_Specify          = tbSergery3.Text;
                        EHS.Hts_Immunity                 = Convert.ToBoolean(radioGroupImmunity4.EditValue);
                        EHS.Hts_Immunity_Specify         = tbImmunity4.Text;
                        EHS.Hts_Family                   = Convert.ToBoolean(radioGroupFamily5.EditValue);
                        EHS.Hts_Family_Specify           = string.Empty;
                        EHS.Hts_Medicine                 = Convert.ToBoolean(radioGroupMedicine6.EditValue);
                        EHS.Hts_Medicine_Specify         = tbMedicine6.Text;
                        EHS.Hts_MedicineAllergic         = Convert.ToBoolean(radioGroupMedicineAllergic7.EditValue);
                        EHS.Hts_MedicineAllergic_Specify = tbMedicineAllergic7.Text;
                        EHS.Hts_Smoking                  = Convert.ToInt32(radioGroupSmoking8.EditValue);
                        EHS.Hts_Smoking_PresentCount     = Convert.ToInt32(tbPresentCount8.EditValue ?? "0");
                        EHS.Hts_Smoking_QuitYear         = Convert.ToInt32(tbQuitYear8.EditValue ?? "0");
                        EHS.Hts_Smoking_QuitMonth        = Convert.ToInt32(tbQuitMonth8.EditValue ?? "0");
                        EHS.Hts_Somking_BeforeQuitCount  = Convert.ToInt32(tbBeforeQuitCount8.EditValue ?? "0");
                        EHS.Hts_Drinking                 = Convert.ToInt32(radioGroupDrinking9.EditValue);
                        EHS.Hts_Drinking_QuitYear        = Convert.ToInt32(tbQuitYear9.EditValue ?? "0");
                        EHS.Hts_Drinking_QuitMonth       = Convert.ToInt32(tbQuitMonth9.EditValue ?? "0");
                        EHS.Hts_Addictive                = Convert.ToBoolean(radioGroupAddictive10.EditValue);
                        EHS.Hts_Addictive_Specify        = tbAddictive10.Text;
                        EHS.Hts_Others                   = tbOthers11.Text;
                        EHS.Hts_Rem            = "Remark";
                        EHS.Hts_CreateBy       = 0;
                        EHS.Hts_ModifyDateTime = date_sv;
                        EHS.Hts_ModifyBy       = 0;
                        EHS.Hts_Status         = 0;
                        EHS.Hts_Del            = 0;
                        EHS.Emp_Key            = this.emp_id;
                        db.HistorySicknesses.InsertOnSubmit(EHS);
                        db.SubmitChanges();

                        EHS_id = EHS.Hts_Key;
                    }
                    else
                    {
                        //Update
                        MssBox.iWaitForm(splashScreenManager1);
                        if (MssBox.QuestionYesNo("คุณต้องการอัพเดตข้อมูลประวัติการป่วย ใช่หรือไม่") == System.Windows.Forms.DialogResult.No)
                        {
                            return;
                        }
                        MssBox.iWaitForm(splashScreenManager1);

                        EHS_id = getdatafor_sickness.Hts_Key;

                        getdatafor_sickness.Hts_DiseaseChronic         = Convert.ToBoolean(radioGroupDiseaseChronic2.EditValue);
                        getdatafor_sickness.Hts_DiseaseChronic_Specify = tbDiseaseChronic2.Text;
                        getdatafor_sickness.Hts_Sergery                  = Convert.ToBoolean(radioGroupSergery3.EditValue);
                        getdatafor_sickness.Hts_Sergery_Specify          = tbSergery3.Text;
                        getdatafor_sickness.Hts_Immunity                 = Convert.ToBoolean(radioGroupImmunity4.EditValue);
                        getdatafor_sickness.Hts_Immunity_Specify         = tbImmunity4.Text;
                        getdatafor_sickness.Hts_Family                   = Convert.ToBoolean(radioGroupFamily5.EditValue);
                        getdatafor_sickness.Hts_Family_Specify           = string.Empty;
                        getdatafor_sickness.Hts_Medicine                 = Convert.ToBoolean(radioGroupMedicine6.EditValue);
                        getdatafor_sickness.Hts_Medicine_Specify         = tbMedicine6.Text;
                        getdatafor_sickness.Hts_MedicineAllergic         = Convert.ToBoolean(radioGroupMedicineAllergic7.EditValue);
                        getdatafor_sickness.Hts_MedicineAllergic_Specify = tbMedicineAllergic7.Text;
                        getdatafor_sickness.Hts_Smoking                  = Convert.ToInt32(radioGroupSmoking8.EditValue);
                        getdatafor_sickness.Hts_Smoking_PresentCount     = Convert.ToInt32(tbPresentCount8.EditValue ?? "0");
                        getdatafor_sickness.Hts_Smoking_QuitYear         = Convert.ToInt32(tbQuitYear8.EditValue ?? "0");
                        getdatafor_sickness.Hts_Smoking_QuitMonth        = Convert.ToInt32(tbQuitMonth8.EditValue ?? "0");
                        getdatafor_sickness.Hts_Somking_BeforeQuitCount  = Convert.ToInt32(tbBeforeQuitCount8.EditValue ?? "0");
                        getdatafor_sickness.Hts_Drinking                 = Convert.ToInt32(radioGroupDrinking9.EditValue);
                        getdatafor_sickness.Hts_Drinking_QuitYear        = Convert.ToInt32(tbQuitYear9.EditValue ?? "0");
                        getdatafor_sickness.Hts_Drinking_QuitMonth       = Convert.ToInt32(tbQuitMonth9.EditValue ?? "0");
                        getdatafor_sickness.Hts_Addictive                = Convert.ToBoolean(radioGroupAddictive10.EditValue);
                        getdatafor_sickness.Hts_Addictive_Specify        = tbAddictive10.Text;
                        getdatafor_sickness.Hts_Others                   = tbOthers11.Text;
                        getdatafor_sickness.Hts_Rem            = "Remark";
                        getdatafor_sickness.Hts_CreateBy       = 0;
                        getdatafor_sickness.Hts_ModifyDateTime = date_sv;
                        getdatafor_sickness.Hts_ModifyBy       = 0;
                        getdatafor_sickness.Hts_Status         = 0;
                        getdatafor_sickness.Hts_Del            = 0;
                        getdatafor_sickness.Emp_Key            = this.emp_id;
                        db.SubmitChanges();
                    }

                    if (sickn_ls.Count > 0)
                    {
                        var _Sicklnjury = new List <HistorySickness_SickInjury>();
                        foreach (var item in sickn_ls)
                        {
                            if (item.Htss_Key == 0)
                            {
                                var set_data = new HistorySickness_SickInjury()
                                {
                                    Htss_SicknessInjury = item.Htss_SicknessInjury,
                                    Htss_OnYear         = item.Htss_OnYear,
                                    Htss_Rem            = "Remark",
                                    Htss_CreateBy       = 0,
                                    Htss_ModifyDateTime = date_sv,
                                    Htss_ModifyBy       = 0,
                                    Htss_Status         = 0,
                                    Htss_Del            = 0,
                                    Hts_Key             = EHS_id
                                };
                                _Sicklnjury.Add(set_data);
                            }
                            else
                            {
                                var get_Update = (from i in db.HistorySickness_SickInjuries where i.Htss_Key == item.Htss_Key select i).FirstOrDefault();
                                get_Update.Htss_SicknessInjury = item.Htss_SicknessInjury;
                                get_Update.Htss_OnYear         = item.Htss_OnYear;
                                get_Update.Htss_Rem            = "Remark";
                                get_Update.Htss_CreateBy       = 0;
                                get_Update.Htss_ModifyDateTime = date_sv;
                                get_Update.Htss_ModifyBy       = 0;
                                get_Update.Htss_Status         = 0;
                                get_Update.Htss_Del            = 0;
                                db.SubmitChanges();
                            }
                        }
                        db.HistorySickness_SickInjuries.InsertAllOnSubmit(_Sicklnjury);
                    }

                    if (family_ls.Count > 0)
                    {
                        var _Family = new List <HistorySickness_Family>();
                        foreach (var item in family_ls)
                        {
                            if (item.Htsf_Key == 0)
                            {
                                var set_data = new HistorySickness_Family()
                                {
                                    Htsf_Relation       = item.Htsf_Relation,
                                    Htsf_Disease        = item.Htsf_Disease,
                                    Htsf_Rem            = "Remark",
                                    Htsf_CreateBy       = 0,
                                    Htsf_ModifyDateTime = date_sv,
                                    Htsf_ModifyBy       = 0,
                                    Htsf_Status         = 0,
                                    Htsf_Del            = 0,
                                    Hts_Key             = EHS_id
                                };
                                _Family.Add(set_data);
                            }
                            else
                            {
                                var get_Update = (from i in db.HistorySickness_Families where i.Htsf_Key == item.Htsf_Key select i).FirstOrDefault();
                                get_Update.Htsf_Relation       = item.Htsf_Relation;
                                get_Update.Htsf_Disease        = item.Htsf_Disease;
                                get_Update.Htsf_Rem            = "Remark";
                                get_Update.Htsf_CreateBy       = 0;
                                get_Update.Htsf_ModifyDateTime = date_sv;
                                get_Update.Htsf_ModifyBy       = 0;
                                get_Update.Htsf_Status         = 0;
                                get_Update.Htsf_Del            = 0;
                                db.SubmitChanges();
                            }
                        }
                        db.HistorySickness_Families.InsertAllOnSubmit(_Family);
                    }

                    #region Delete Detail sickness && family
                    var get_del_sikn = (from i in db.HistorySickness_SickInjuries where for_del_sickn.Contains(i.Htss_Key.ToString()) select i).ToList();
                    if (get_del_sikn.Count > 0)
                    {
                        db.HistorySickness_SickInjuries.DeleteAllOnSubmit(get_del_sikn);
                        db.SubmitChanges();
                    }

                    var get_del_fami = (from i in db.HistorySickness_Families where for_del_fam.Contains(i.Htsf_Key.ToString()) select i).ToList();
                    if (get_del_fami.Count > 0)
                    {
                        db.HistorySickness_Families.DeleteAllOnSubmit(get_del_fami);
                        db.SubmitChanges();
                    }
                    #endregion

                    db.SubmitChanges();
                    ts.Complete();
                    MssBox.iWaitForm(splashScreenManager1);
                    MssBox.Success();
                }
                #endregion
            }
            catch (Exception ex)
            {
                MssBox.iWaitForm(splashScreenManager1);
                MssBox.Error(ex);
            }
        }