Ejemplo n.º 1
0
 private void btnConfigSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.DataCheck())
         {
             if (!File.Exists(IniRead.path))
             {
                 File.Create(IniRead.path);
             }
             IniRead.WritePrivateProfileString("File", "File1Path", this.file_1.get_TextBoxFile().Text);
             IniRead.WritePrivateProfileString("File", "File2Path", this.file_2.get_TextBoxFile().Text);
             IniRead.WritePrivateProfileString("File", "TableInFile1", this.com_sheet_1.Text);
             IniRead.WritePrivateProfileString("File", "TableInFile2", this.com_sheet_2.Text);
             IniRead.WritePrivateProfileString("FieldCon", "FileNumber", this.radioButton1.Checked ? "1" : "2");
             foreach (DataGridViewRow row in (IEnumerable)this.dataGridView1.Rows)
             {
                 string val    = Convert.ToString(row.Cells["WenJianLie"].Value);
                 int    result = 0;
                 int    num2   = 0;
                 if (val == string.Empty)
                 {
                     val = "0.0";
                 }
                 else
                 {
                     if (val.Length <= 2)
                     {
                         MessageManager.ShowMsgBox("INP-271205");
                         return;
                     }
                     if (val[1] != '.')
                     {
                         MessageManager.ShowMsgBox("INP-271205");
                         return;
                     }
                     if (!(int.TryParse(val.Substring(0, val.IndexOf('.')), out result) && int.TryParse(val.Substring(val.LastIndexOf('.') + 1), out num2)))
                     {
                         MessageManager.ShowMsgBox("INP-271205");
                         return;
                     }
                 }
                 IniRead.WritePrivateProfileString("FieldCon", row.Cells["key"].Value.ToString(), val);
             }
             IniRead.WritePrivateProfileString("FieldCon", "DefaultFuHeRen", Convert.ToString(this.dataGridView1.Rows[6].Cells["MoRen"].Value));
             IniRead.WritePrivateProfileString("FieldCon", "DefaultShouKuanRen", Convert.ToString(this.dataGridView1.Rows[7].Cells["MoRen"].Value));
             IniRead.WritePrivateProfileString("FieldCon", "DefaultShuiLv", Convert.ToString(this.dataGridView1.Rows[0x13].Cells["MoRen"].Value));
             IniRead.WritePrivateProfileString("FieldCon", "Invtype", this.invtype.ToString());
             IniRead.WritePrivateProfileString("FieldCon", "IsSeted", "1");
             IniRead.WritePrivateProfileString("TableCon", "MainTableField", Regex.Match(this.combo_1.Text, @"^\[\d+\]").Value.Trim(new char[] { '[', ']' }));
             IniRead.WritePrivateProfileString("TableCon", "AssistantTableField", Regex.Match(this.combo_2.Text, @"^\[\d+\]").Value.Trim(new char[] { '[', ']' }));
             IniRead.WritePrivateProfileString("TableCon", "MainTableIgnoreRow", this.txt_1.Text);
             IniRead.WritePrivateProfileString("TableCon", "AssistantTableIgnoreRow", this.txt_2.Text);
             MessageBoxHelper.Show("保存完成", "保存", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             base.Close();
         }
     }
     catch (Exception exception)
     {
         MessageBoxHelper.Show(exception.ToString(), "异常");
     }
 }