Example #1
0
 public static void SaveSettings(ModuleSettings settings)
 {
     string fileName= System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath , GetSettingsFile());
     XmlSerializer seriallizer=new XmlSerializer(typeof(ModuleSettings));
     FileStream fs=new FileStream(fileName,FileMode.Create);
     seriallizer.Serialize(fs,settings);
     fs.Close();
 }
Example #2
0
        public void ShowInsuranceC46(int IQuarter, int IYear, string SocialInsuranceOffice, string ComName, string ComAddress, string ComAcc,
            string ComBank, string ComTel, string ComFax, string YC1, string YC2, string YC3, string YC4, 
            string YC5, string YC6, string YC7, string YC8, DateTime CreateDate, string CopyNum, string ComID)
        {
            //ReportDocument rptDoc = new ReportDocument();
            ReportDocument rptDoc = null;
            //rptDoc.Load(@"Reports\BHXH\InsuranceC46.rpt");
            rptDoc = new Reports.BHXH.InsuranceC46();
            rptDoc.Refresh();
            rptDoc.SetDatabaseLogon(WorkingContext.Setting.UserName, WorkingContext.Setting.Password, WorkingContext.Setting.Server, WorkingContext.Setting.Database);
            rptDoc.DataDefinition.ParameterFields["IQuarter"].ApplyCurrentValues(GetReportPara(IQuarter));
            rptDoc.DataDefinition.ParameterFields["IYear"].ApplyCurrentValues(GetReportPara(IYear));
            rptDoc.DataDefinition.ParameterFields["SocialInsuranceOffice"].ApplyCurrentValues(GetReportPara(SocialInsuranceOffice));
            rptDoc.DataDefinition.ParameterFields["ComName"].ApplyCurrentValues(GetReportPara(ComName));
            rptDoc.DataDefinition.ParameterFields["ComAddress"].ApplyCurrentValues(GetReportPara(ComAddress));
            rptDoc.DataDefinition.ParameterFields["ComAcc"].ApplyCurrentValues(GetReportPara(ComAcc));
            rptDoc.DataDefinition.ParameterFields["ComBank"].ApplyCurrentValues(GetReportPara(ComBank));
            rptDoc.DataDefinition.ParameterFields["ComTel"].ApplyCurrentValues(GetReportPara(ComTel));
            rptDoc.DataDefinition.ParameterFields["ComFax"].ApplyCurrentValues(GetReportPara(ComFax));
            rptDoc.DataDefinition.ParameterFields["YC1"].ApplyCurrentValues(GetReportPara(YC1));
            rptDoc.DataDefinition.ParameterFields["YC2"].ApplyCurrentValues(GetReportPara(YC2));
            rptDoc.DataDefinition.ParameterFields["YC3"].ApplyCurrentValues(GetReportPara(YC3));
            rptDoc.DataDefinition.ParameterFields["YC4"].ApplyCurrentValues(GetReportPara(YC4));
            rptDoc.DataDefinition.ParameterFields["YC5"].ApplyCurrentValues(GetReportPara(YC5));
            rptDoc.DataDefinition.ParameterFields["YC6"].ApplyCurrentValues(GetReportPara(YC6));
            rptDoc.DataDefinition.ParameterFields["YC7"].ApplyCurrentValues(GetReportPara(YC7));
            rptDoc.DataDefinition.ParameterFields["YC8"].ApplyCurrentValues(GetReportPara(YC8));
            rptDoc.DataDefinition.ParameterFields["CreateDate"].ApplyCurrentValues(GetReportPara(CreateDate));
            rptDoc.DataDefinition.ParameterFields["CopyNum"].ApplyCurrentValues(GetReportPara(CopyNum));
            rptDoc.DataDefinition.ParameterFields["ComID"].ApplyCurrentValues(GetReportPara(ComID));
            if (rptDoc != null)
            {
                SetDBLogonForReport(rptDoc);
            }
            crViewer.ReportSource = rptDoc;

            settings = ModuleConfig.GetSettings();
            string reportPart = settings.ReportPath;
            string Targetfile = reportPart + "\\" + "BHXH mẫu C46" + "_" + IYear + ".rpt";
            FileInfo fil = new FileInfo(Targetfile);
            if (fil.Exists)
                if (
                    MessageBox.Show("Đã tồn tại báo cáo này, có ghi đè không?", "Thông báo", MessageBoxButtons.YesNo) ==
                    DialogResult.Yes)
                {
                    fil.Delete();
                }
                else
                {
                    return;
                }
            //reportDocument.SaveAs(Targetfile, true);
            //Application.DoEvents();
            rptDoc.ExportToDisk(ExportFormatType.CrystalReport, Targetfile);

            this.Show();
        }
Example #3
0
        /// <summary>
        /// Get the Setting values from a config file
        /// </summary>
        /// <returns>Module Setting with all settings value</returns>
        public static ModuleSettings GetSettings()
        {
            XmlSerializer  serializer = new XmlSerializer(typeof(ModuleSettings));
            ModuleSettings settings   = null;
            string         filePath   = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, GetSettingsFile());

            try
            {
                FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                //Deserialize the data
                settings = (ModuleSettings)serializer.Deserialize(fs);
                fs.Close();
            }
            catch (System.IO.FileNotFoundException ex)
            {
                //do something throw exception
                MessageBox.Show(ex.Message);
            }
            return(settings);
        }
Example #4
0
        private void tbaMain_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
        {
            switch (Convert.ToString(e.Button.Tag))
            {
                case "DangNhap":
                    settingsModule= new  ModuleSettings();
                    settingsModule = ModuleConfig.GetSettings();

                    if (WorkingContext.CheckConnection(settingsModule.Server, settingsModule.Database, settingsModule.UserName, settingsModule.Password))
                    {
                        AdminDO adminDO = new AdminDO();
                        EmployeeDO employeeDO = new EmployeeDO();
                        dsUser = adminDO.GetAllUsers();
                        dsEmployee = employeeDO.GetAllEmployees(1);
                        if (dsUser.Tables[0].Rows.Count == 0 || dsEmployee.Tables[0].Rows.Count == 0)
                        {
                            NotLogin(true);
                        }
                        else
                            login.ShowDialog(this);
                    }
                    else
                    {
                        string str4 = WorkingContext.LangManager.GetString("frmSetting_Error1_Title");
                        string str5 = WorkingContext.LangManager.GetString("frmSetting_Error2");
                        //MessageBox.Show("Không thể kết nối được cơ sở dữ liệu. Hãy nhập lại thông số cấu hình hệ thống", "Lỗi", MessageBoxButtons.OK,  MessageBoxIcon.Error);
                        MessageBox.Show(str5, str4, MessageBoxButtons.OK, MessageBoxIcon.Error);

                        frmSettings settings = new frmSettings();
                        settings.ShowDialog(this);
                        this.Refresh();
                    }
                    break;
                case "Search":
                    if (CheckMdiClientDuplicates("frmSearch"))
                    {
                        frmSearch search = new frmSearch();
                        search.Show();
                        search.MdiParent = this;
                    }
                    break;
                case "Report":
                    if (CheckMdiClientDuplicates("frmListReport"))
                    {
                        frmListReport report = new frmListReport();
                        report.Show();
                        report.MdiParent = this;
                    }

                    break;
                case "Status":
                    if (CheckMdiClientDuplicates("frmEmployeeStatus"))
                    {
                        frmEmployeeStatus status = new frmEmployeeStatus();
                        status.Show();
                        status.MdiParent = this;
                    }
                    break;
                case "Schedule":
                    if (CheckMdiClientDuplicates("frmRegWorkingTime"))
                    {
                        frmRegWorkingTime workingTime1 = new frmRegWorkingTime();
                        workingTime1.Show();
                        workingTime1.MdiParent = this;
                    }
                    break;
                case "Manage":
                    if (CheckMdiClientDuplicates("frmListEmployees"))
                    {
                        frmListEmployees listEmployees = new frmListEmployees();
                        listEmployees.Show();
                        listEmployees.MdiParent = this;
                    }
                    break;
                case "Salary":
                    if (CheckMdiClientDuplicates("frmListSalary"))
                    {
                        frmListSalary salary = new frmListSalary();
                        salary.Show();
                        salary.MdiParent = this;
                    }
                    break;
                case "TimeSheet":
                    if (CheckMdiClientDuplicates("frmTimeSheet"))
                    {
                        frmTimeSheet timesheet = new frmTimeSheet();
                        timesheet.Show();
                        timesheet.MdiParent = this;
                    }
                    break;
                case "Settings":
                    frmSettings frmsettings = new frmSettings();
                    frmsettings.ShowDialog(this);
                    this.Refresh();
                    break;
                case "Help":
                    MessageBox.Show("Chức năng này đang được xây dựng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                case "Antrua":
                    if (CheckMdiClientDuplicates("frmLunch"))
                    {
                        frmLunch frm = new frmLunch();
                        frm.Show();
                        frm.MdiParent = this;
                    }
                    break;
                case "Exit":
                    string str = WorkingContext.LangManager.GetString("frmMain_MessaThem");
                    string str1 = WorkingContext.LangManager.GetString("frmMain_MessaThem1");
                    if (MessageBox.Show(str, str1, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Application.Exit();
                    }
                    break;
            }
        }
Example #5
0
        //menu dang nhap hệ thống
        private void mnuDangNhap_Click(object sender, EventArgs e)
        {
            settingsModule = ModuleConfig.GetSettings();

            if (WorkingContext.CheckConnection(settingsModule.Server, settingsModule.Database, settingsModule.UserName, settingsModule.Password))
            {
                AdminDO adminDO = new AdminDO();
                EmployeeDO employeeDO = new EmployeeDO();
                dsUser = adminDO.GetAllUsers();
                dsEmployee = employeeDO.GetAllEmployees(1);
                if (dsUser.Tables[0].Rows.Count == 0 || dsEmployee.Tables[0].Rows.Count == 0)
                {
                    NotLogin(true);
                }
                else
                    login.ShowDialog(this);
            }
            else
            {
                string str4 = WorkingContext.LangManager.GetString("frmSetting_Error1_Title");
                string str5 = WorkingContext.LangManager.GetString("frmSetting_Error2");
                //MessageBox.Show("Không thể kết nối được cơ sở dữ liệu. Hãy nhập lại thông số cấu hình hệ thống", "Lỗi", MessageBoxButtons.OK,  MessageBoxIcon.Error);
                MessageBox.Show(str5, str4, MessageBoxButtons.OK, MessageBoxIcon.Error);

                frmSettings frmsettings = new frmSettings();
                frmsettings.ShowDialog(this);
                this.Refresh();
            }
        }
Example #6
0
        public frmMain()
        {
            ShowSplashScreen();
            InitializeComponent();
            this.Refresh();
            //SetMenuStatus(false);
            this.Show();
            this.Activate();
            login = new frmLogin(this);

            AdminDO adminDO = new AdminDO();
            EmployeeDO employeeDO = new EmployeeDO();

            settingsModule = new ModuleSettings();
            settingsModule = ModuleConfig.GetSettings();

            if (!WorkingContext.CheckConnection(settingsModule.Server, settingsModule.Database, settingsModule.UserName, settingsModule.Password))
            {
                string str4 = WorkingContext.LangManager.GetString("frmSetting_Error1_Title");
                string str5 = WorkingContext.LangManager.GetString("frmSetting_Error2");
                //MessageBox.Show("Không thể kết nối được cơ sở dữ liệu. Hãy nhập lại thông số cấu hình hệ thống", "Lỗi", MessageBoxButtons.OK,  MessageBoxIcon.Error);
                MessageBox.Show(str5, str4, MessageBoxButtons.OK, MessageBoxIcon.Error);

                frmSettings frm = new frmSettings();
                frm.ShowDialog(this);
            }
            else
            {

                dsUser = adminDO.GetAllUsers();
                dsEmployee = employeeDO.GetAllEmployees(1);

                if (dsUser.Tables[0].Rows.Count == 0 || dsEmployee.Tables[0].Rows.Count == 0)
                {
                    NotLogin(true);
                }
                else
                    login.ShowDialog(this);
            }
        }
Example #7
0
        private void btnHelp_Click(object sender, EventArgs e)
        {
            settings = ModuleConfig.GetSettings();
            //string reportPart = settings.ReportPath;

            OpenFileDialog ofd = new OpenFileDialog();
            //ofd.Filter = "All File|*.*|CrystalReports|*.rpt";
            ofd.InitialDirectory = WorkingContext.Setting.ReportPath;
            ofd.FilterIndex = 1;

            string ReportFilePath = "";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                ReportFilePath = ofd.FileName;
                ReportFileName = Path.GetFileName(ReportFilePath);

                #region ShowReport

                ReportDocument rptDoc = new ReportDocument();
                PleaseWait.ShowProcess();

                try
                {
                    // Load the report
                    //rptDoc.Load(@"Reports/BHXH/InsuranceSDH02.rpt");
                    rptDoc.Load(ReportFilePath);
                }
                catch (LoadSaveReportException Exp)
                {
                    //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                    string str = WorkingContext.LangManager.GetString("frmListReport_Error_Messa1");
                    string str1 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa2");
                    //MessageBox.Show("Không tìm thấy đường dẫn của file báo cáo..", "Lỗi đọc file báo cáo.");
                    MessageBox.Show(str, str1);
                }
                catch (Exception Exp)
                {
                    //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                    string str2 = WorkingContext.LangManager.GetString("frmListReport_Error_Messa3");

                    //MessageBox.Show(Exp.Message, "Có lỗi xảy ra");
                    MessageBox.Show(Exp.Message, str2);
                }

                if (rptDoc != null)
                {
                    SetDBLogonForReport(rptDoc);
                }
                PleaseWait.CloseProcess();
                frmReportPreview frm = new frmReportPreview();
                frm.ExportReport = false;

                frm.SetReportDocument = rptDoc;
                frm.Show();
            }

                #endregion
        }
Example #8
0
        private void frmLptDetailEmployee_Load(object sender, EventArgs e)
        {
            crvDetail.ReportSource = reportDocument;

            //kiem tra tuy chon ExportRepost
            if (ExportReport)
            {
                settings = ModuleConfig.GetSettings();
                string reportPart = settings.ReportPath;
                string Targetfile = reportPart + "\\" + reportName + "_" + reportDate.Month + "_" + reportDate.Year + ".rpt";
                FileInfo fil = new FileInfo(Targetfile);
                if (fil.Exists)
                    if (
                        MessageBox.Show("Đã tồn tại báo cáo này, có ghi đè không?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        fil.Delete();
                    }
                    else
                    {
                        return;
                    }
                //reportDocument.SaveAs(Targetfile, true);
                //Application.DoEvents();
                reportDocument.ExportToDisk(ExportFormatType.CrystalReport, Targetfile);
            }
        }
Example #9
0
        //        private void RestoreSettings()
        //        {
        //            Setting newSetting;
        //
        //            try
        //            {
        //                newSetting = ((Setting) WorkingContext.Setting.Restore());
        //
        //            }
        //            catch (UserSettingsException ex)
        //            {
        //                // in case of failure, keep current WorkingContext.Settings
        //                MessageBox.Show(ex.ToString());
        //                newSetting = WorkingContext.Setting;
        //
        //            }
        //
        //            WorkingContext.Setting = newSetting;
        //
        //            UpdateDisplay();
        //
        //        }
        /// <summary>
        /// Hiển thị thông tin cấu hình
        /// </summary>
        //        private void UpdateDisplay()
        //        {
        //            txtServer.Text = WorkingContext.Setting.Server;
        //            txtDatabase.Text = WorkingContext.Setting.Database;
        //            txtUserName.Text = WorkingContext.Setting.UserID;
        //            txtPassWord.Text = WorkingContext.Setting.Password;
        //
        //            txtPicturePath.Text = WorkingContext.Setting.PicturePath;
        //        }
        /// <summary>
        /// 
        /// </summary>
        private void getSettings()
        {
            LoadServerCbo();
            settings = ModuleConfig.GetSettings();
            txtDatabase.Text = settings.Database;
            txtUserName.Text = settings.UserName;
            txtPassWord.Text = settings.Password;
            txtServer.Text = settings.Server;
            txtPicturePath.Text = settings.PicturePath;
            txtReportPath.Text = settings.ReportPath;
            switch(settings.Language)
            {
                case "en-US" :
                    rdoEnglish.Checked = true;
                    break;
                case "vi-VN" :
                    rdoVietnamese.Checked = true;
                    break;
                case "ja-JP":
                    rdoJapanese.Checked = true;
                    break;

            }
        }
Example #10
0
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            if(WorkingContext.CheckConnection(txtServer.Text,txtDatabase.Text,txtUserName.Text,txtPassWord.Text))
            {
                ModuleSettings newSettings = new ModuleSettings();
                newSettings.Database=txtDatabase.Text.Trim();
                newSettings.Password = txtPassWord.Text.Trim();
                newSettings.UserName = txtUserName.Text.Trim();
                newSettings.Server = txtServer.Text.Trim();
                newSettings.PicturePath = txtPicturePath.Text.Trim();
                newSettings.ReportPath = txtReportPath.Text.Trim();
                if(rdoEnglish.Checked)
                {
                    newSettings.Language = "en-US";
                }
                else if(rdoVietnamese.Checked)
                {
                    newSettings.Language = "vi-VN";
                }
                else if(rdoJapanese.Checked)
                {
                    newSettings.Language = "ja-JP";
                }

            //				WorkingContext.Setting.Server = txtServer.Text;
            //				WorkingContext.Setting.Database = txtDatabase.Text;
            //				WorkingContext.Setting.UserID = txtUserID.Text;
            //				WorkingContext.Setting.Password = txtPassword.Text;
            //
            //				WorkingContext.Setting.PicturePath = txtPicturePath.Text;
                try
                {
            //					WorkingContext.Setting.Save();
                    ModuleConfig.SaveSettings(newSettings);

                }

                catch
                {
                    string str1 = WorkingContext.LangManager.GetString("frmSetting_Error1");
                    string str3 = WorkingContext.LangManager.GetString("frmSetting_Error1_Title");
                    //MessageBox.Show("Không thể tạo file cấu hình hệ thống", "Lỗi", MessageBoxButtons.OK,  MessageBoxIcon.Error);
                    MessageBox.Show(str1, str3, MessageBoxButtons.OK,  MessageBoxIcon.Error);
                    return;
                }
                string str = WorkingContext.LangManager.GetString("frmSetting_ThongBao_Messa");
                string str2 = WorkingContext.LangManager.GetString("frmSetting_ThongBao_Title");
                MessageBox.Show(str, str2, MessageBoxButtons.OK,  MessageBoxIcon.Information);
                WorkingContext.InitWorkingContext();
                this.Close();
            }
            else
            {
                string str4 = WorkingContext.LangManager.GetString("frmSetting_Error1_Title");
                string str5 = WorkingContext.LangManager.GetString("frmSetting_Error2");
                //MessageBox.Show("Không thể kết nối được cơ sở dữ liệu. Hãy nhập lại thông số cấu hình hệ thống", "Lỗi", MessageBoxButtons.OK,  MessageBoxIcon.Error);
                MessageBox.Show(str5, str4, MessageBoxButtons.OK,  MessageBoxIcon.Error);
            }
        }
Example #11
0
        //            settings = ModuleConfig.GetSettings();
        //            private static ModuleSettings setting;
        /// <summary>
        /// Khởi tạo ngôn ngữ mặc định là tiếng Việt
        /// </summary>
        /// <returns>Mã lỗi xuất hiện khi thực hiện kết nối đến CSDL</returns>
        /// 
        public static int InitWorkingContext()
        {
            //				setting = new Setting(UserStorageOption.File);
                setting = ModuleConfig.GetSettings();
            //				setting = new ModuleSettings();
            //				RestoreSettings();
                language = "ja-JP";//ConfigurationSettings.AppSettings["CurrentLanguage"];
                language = setting.Language;
                langManager = new LangManager(language);

                return 0;
        }
Example #12
0
        public void ShowInsuranceC47(DataSet ds,int IMonth,int IYear)
        {
            //ReportDocument rptDoc = new ReportDocument();
            ReportDocument rptDoc = null;
            //rptDoc.Load(@"Reports\BHXH\InsuranceC47.rpt");
            rptDoc = new Reports.BHXH.InsuranceC47();
            rptDoc.Refresh();
            rptDoc.SetDatabaseLogon(WorkingContext.Setting.UserName, WorkingContext.Setting.Password, WorkingContext.Setting.Server, WorkingContext.Setting.Database);
            rptDoc.SetDataSource(ds);
            rptDoc.Subreports["Part2"].SetDataSource(ds);
            rptDoc.DataDefinition.ParameterFields["IMonth"].ApplyCurrentValues(GetReportPara((object)IMonth));
            rptDoc.DataDefinition.ParameterFields["IYear"].ApplyCurrentValues(GetReportPara(IYear));
            if (rptDoc != null)
            {
                SetDBLogonForReport(rptDoc);
            }
            crViewer.ReportSource = rptDoc;

            settings = ModuleConfig.GetSettings();
            string reportPart = settings.ReportPath;
            string Targetfile = reportPart + "\\" + "BHXH mẫu C47" + "_" + IMonth + "_" + IYear + ".rpt";
            FileInfo fil = new FileInfo(Targetfile);
            if (fil.Exists)
                if (
                    MessageBox.Show("Đã tồn tại báo cáo này, có ghi đè không?", "Thông báo", MessageBoxButtons.YesNo) ==
                    DialogResult.Yes)
                {
                    fil.Delete();
                }
                else
                {
                    return;
                }
            //reportDocument.SaveAs(Targetfile, true);
            //Application.DoEvents();
            rptDoc.ExportToDisk(ExportFormatType.CrystalReport, Targetfile);

            this.Show();
        }