/// <summary> /// 点击"确定",新建和编辑人员时执行不同的操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(PeopleNameTextBox.Text) || string.IsNullOrWhiteSpace(PeopleNameTextBox.Text)) { MessageBox.Show("人员姓名不能为空!", "姓名输入错误", MessageBoxButton.OK, MessageBoxImage.Warning); this.PeopleNameTextBox.Focus(); return; } if (isNew == true) { if (SettingDataBase.IsExistPeople(PeopleNameTextBox.Text)) { MessageBox.Show("已有同名人员,请输入不同的名字。", "重名", MessageBoxButton.OK, MessageBoxImage.Warning); } else { this.DialogResult = true; } } else { if (SettingDataBase.IsExistPeople(oldName)) { this.DialogResult = true; } } }
/// <summary> /// 默认构造函数 /// </summary> public Company() { // 实例化时对People成员进行初始化赋值,将人员列表赋给People集合 List <string> s = SettingDataBase.ReadCompanyPeople(); s.ForEach(i => People.Add(i)); }
/// <summary> /// 赋值项目数据 /// </summary> private void InitialProjectBasicInfo() { if (Program.currentProject != null) { dt.Clear(); this.DrawerComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.WriterComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.CheckerComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.InspectorComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.ApproverComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.FinalApproverComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); string prj = Program.currentProject; this.ProjectNameTextBox.Text = prj; this.ProjectProvinceTextBox.Text = ProjectDataBase.ReadProjectProvince(prj); this.ProjectCityTextBox.Text = ProjectDataBase.ReadProjectCity(prj); string[] company = ProjectDataBase.ReadProjectCompany(prj); this.CompanyNameTextBox.Text = company[0]; this.CompanyCodeTextBox.Text = company[1]; this.DrawerComboBox.Text = company[2]; this.WriterComboBox.Text = company[3]; this.CheckerComboBox.Text = company[4]; this.InspectorComboBox.Text = company[5]; this.ApproverComboBox.Text = company[6]; this.FinalApproverComboBox.Text = company[7]; InitialDataTable(ProjectDataBase.ReadLayerNumberList(prj), ProjectDataBase.ReadLayerNameList(prj), ProjectDataBase.ReadLayerGeoList(prj), ProjectDataBase.ReadLayerDescriptionList(prj)); } }
/// <summary> /// 方法,刷新人员列表,清空人员列表People,将数据库中的人员数据赋值给People /// </summary> public void RefreshPeople() { People.Clear(); List <string> s = SettingDataBase.ReadCompanyPeople(); for (int i = 0; i < s.Count; i++) { People.Add(s[i]); } }
/// <summary> /// 无参数的构造函数 /// </summary> public ProjectCompany() { InitializeComponent(); // 填充公司名称和资质代码 this.CompanyNameTextBox.Text = SettingDataBase.ReadCompanyName(); this.CompanyCodeTextBox.Text = SettingDataBase.ReadCompanyCode(); // 设置ComboBox数据 InitialComboBox(); }
/// <summary> /// 设置ComboBox数据 /// </summary> private void InitialComboBox() { if (SettingDataBase.ReadCompanyPeople() != null) { this.DrawerComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.WriterComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.CheckerComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.InspectorComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.ApproverComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); this.FinalApproverComboBox.ItemsSource = SettingDataBase.ReadCompanyPeople(); } }
/// <summary> /// 点击"项目公司信息设置" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ProjectCompanySettingButton_Click(object sender, RoutedEventArgs e) { // 赋值传递数据,并初始化projectCompany窗体 string name; if (!string.IsNullOrEmpty(projectSetting.CompanyName)) { name = projectSetting.CompanyName; } else { name = SettingDataBase.ReadCompanyName(); } string code; if (!string.IsNullOrEmpty(projectSetting.CompanyCode)) { code = projectSetting.CompanyCode; } else { code = SettingDataBase.ReadCompanyCode(); } string drawer = projectSetting.Drawer; string writer = projectSetting.Writer; string checker = projectSetting.Checker; string inspector = projectSetting.Inspector; string approver = projectSetting.Approver; string finalApprover = projectSetting.FinalApprover; ProjectCompany projectCompany = new ProjectCompany(name, code, drawer, writer, checker, inspector, approver, finalApprover); projectCompany.ShowDialog(); // 点击确定按钮后,刷新projectSetting类中关于公司信息的属性 if (projectCompany.DialogResult == true) { projectSetting.CompanyName = projectCompany.CompanyNameTextBox.Text; projectSetting.CompanyCode = projectCompany.CompanyCodeTextBox.Text; projectSetting.Drawer = projectCompany.DrawerComboBox.Text; projectSetting.Writer = projectCompany.WriterComboBox.Text; projectSetting.Checker = projectCompany.CheckerComboBox.Text; projectSetting.Inspector = projectCompany.InspectorComboBox.Text; projectSetting.Approver = projectCompany.ApproverComboBox.Text; projectSetting.FinalApprover = projectCompany.FinalApproverComboBox.Text; } }
/// <summary> /// Save命令的Executed事件处理函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CommandBindingSave_Executed(object sender, ExecutedRoutedEventArgs e) { // 保存"公司"设置 company.Name = CompanyNameTextBox.Text; company.Code = CompanyCodeTextBox.Text; isDirty = false; // 保存"标准"设置 SettingDataBase.EditIndustrialStandard(industrialStandard); SettingDataBase.EditLocalStandard(localStandard); // 关闭窗口 if (e.Parameter.ToString() == "Commit") { this.Close(); } }
// 程序自检函数,检查必要设置并初始化 private void ProgramCheck() { // 如果数据存储路径注册表项不存在,则新建项并设置默认路径 if (!Program.IsExitProgramPath()) { Program.SetProgramPath(Program.defaultPath); } // 如果"小熠岩土勘察"文件夹不存在,则新建文件夹 if (!System.IO.Directory.Exists(Program.ReadProgramPath())) { System.IO.Directory.CreateDirectory(Program.ReadProgramPath()); } // 如果设置信息数据库不存在,则新建数据库,并初始化数据库表 if (!System.IO.File.Exists(Program.ReadProgramPath() + "\\设置信息.gsygeo")) { SettingDataBase.Create(); } // 清理空数据文件 ProjectDataBase.ClearEmpthProject(); }
/// <summary> /// 方法,编辑人员 /// </summary> /// <param name="_oldName">旧名字</param> /// <param name="_name">新名字</param> public void EditPeople(string _oldName, string _name) { SettingDataBase.EditCompanyPeople(_oldName, _name); RefreshPeople(); }
/// <summary> /// 方法,添加人员 /// </summary> /// <param name="_name">人员名字</param> public void AddPeople(string _name) { SettingDataBase.AddCompanyPeople(_name); RefreshPeople(); }
/// <summary> /// 方法,删除人员 /// </summary> /// <param name="_name">人员名字</param> public void DeletePeople(string _name) { SettingDataBase.DeleteCompanyPeople(_name); RefreshPeople(); }