/// <summary> /// 其他测量类型的录入 /// </summary> /// <param name="mtypeID">类型,用类型表的ID表达</param> /// <param name="nameOfOtherRem">表示其他备注的名称(常规的备注、工况以外的)</param> private void otherMTypeImport(string mtypeID, string nameOfOtherRem) { prepareForEdit(true, true, "本类别备注", true, true, true, true, false, false, false, true, editType.none, ""); //下面再修改当前的录入类型 switch (mtypeID) { case "1": currentEditType = editType.pressD; editTypeName = "基坑压顶水平位移"; break; case "2": currentEditType = editType.subD; editTypeName = "沉降位移"; break; case "3": currentEditType = editType.ropeN; editTypeName = "锚索内力"; break; case "4": currentEditType = editType.supportN; editTypeName = "支撑轴力"; break; case "5": currentEditType = editType.waterD; editTypeName = "地下水水位位移"; break; } #region 读入数据 try { login.conn.Open(); //首先读入总备注 SqlCommand sc = new SqlCommand("select remark from fp_" + proID + "_mtype where ID='" + mtypeID + "'", login.conn); tb_editpro_remarks.Text = sc.ExecuteScalar().ToString(); setSaveState(true);//读入备注的时候会把状态改为已编辑,这里调整保存状态 //读入坐标列表 //坐标列表,用于读出数据时改写pID值 Dictionary<int, string> ptList = new Dictionary<int, string>(); sc.CommandText = "select ID,pName from fp_" + proID + "_PT"; SqlDataReader sdr = sc.ExecuteReader(); while (sdr.Read()) { ptList.Add(sdr.GetInt32(0), sdr.GetString(1)); } sdr.Close(); //读入数据表 SqlDataAdapter sda = new SqlDataAdapter("select * from fp_" + proID + "_" + mtypeID + " order by pID", login.conn); DataTable dt = new DataTable(); sda.Fill(dt); dgv_editpro.Columns.Add("ID", "ID"); dgv_editpro.Columns.Add("pID", "点位"); dgv_editpro.Columns[0].DefaultCellStyle = new DataGridViewCellStyle() { BackColor = Color.Gray }; dgv_editpro.Columns[1].DefaultCellStyle = new DataGridViewCellStyle() { BackColor = Color.Silver }; dgv_editpro.Columns[0].ReadOnly = true; dgv_editpro.Columns[1].ReadOnly = true; //排序后的数据表 DataTable sortedDt = null; //调整日期列 if (dt.Columns.Count > 2) { //读出日期表,用于日期排序 Dictionary<int, long> dateList = new Dictionary<int, long>(); sc.CommandText = "select ID,dateT from fp_" + proID + "_dateRemark"; sdr = sc.ExecuteReader(); while (sdr.Read()) { dateList.Add(sdr.GetInt32(0), sdr.GetInt64(1)); } sdr.Close(); //组出 列名-日期值 的字典 Dictionary<string, long> columnList = new Dictionary<string, long>(); for (int i = 2; i < dt.Columns.Count; i++) { columnList.Add(dt.Columns[i].ColumnName, dateList[Convert.ToInt32(dt.Columns[i].ColumnName.Substring(1))]); } //排序 var sortedcolumnList = columnList.OrderBy(n => n.Value); //组建排序后的列名顺序列表 List<string> newColumnList = new List<string>(); newColumnList.Add("ID"); newColumnList.Add("pID"); foreach (var n in sortedcolumnList) { newColumnList.Add(n.Key); //顺便把排序后的列添加到视图 dgv_editpro.Columns.Add(n.Key, DateTime.FromBinary(n.Value).ToString()); } //根据新的列名顺序,组出新的数据表 sortedDt = dt.DefaultView.ToTable(false, newColumnList.ToArray()); } //锁定数据表排序 for (int i = 0; i < dgv_editpro.Columns.Count; i++) { dgv_editpro.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } //写入数据 DataTable finalDt = sortedDt == null ? dt : sortedDt; foreach (DataRow row in finalDt.Rows) { dgv_editpro.Rows.Add(row.ItemArray); } //写入"备注,工况,其他备注"三行 dgv_editpro.Rows.Add("备注", "-------"); dgv_editpro.Rows.Add("工况", "-------"); dgv_editpro.Rows.Add(nameOfOtherRem, "-------"); sda = new SqlDataAdapter("select remark,condition,otherRem from fp_" + proID + "_dateRemark where mtypeID='" + mtypeID + "' order by dateT", login.conn); DataTable remarkInfo = new DataTable(); sda.Fill(remarkInfo); if (remarkInfo.Rows.Count > 0) { for (int i = 2; i < dgv_editpro.Columns.Count; i++) { for (int j = dgv_editpro.Rows.Count - 3; j < dgv_editpro.Rows.Count; j++) { dgv_editpro.Rows[j].Cells[i].Value = remarkInfo.Rows[i - 2].Field<string>(j - dgv_editpro.Rows.Count + 3); } } } //改写pID for (int i = 0; i < dgv_editpro.Rows.Count - 3; i++) { setCell(i, 1, ptList[Convert.ToInt32(dgv_editpro.Rows[i].Cells[1].Value)]); } } catch (Exception exc) { throw exc; } finally { login.conn.Close(); } #endregion #region 添加行 NLine += (object o, EventArgs ea) => { try { //要求选择某个点位 AddPTDialog aptd = new AddPTDialog(proID); if (aptd.ShowDialog() == DialogResult.OK) { if (aptd.pID != -1) //默认值是-1 { login.conn.Open(); //插入到数据表 SqlCommand sc = new SqlCommand("insert into fp_" + proID + "_" + mtypeID + "(pID) values('" + aptd.pID.ToString() + "')", login.conn); sc.ExecuteNonQuery(); login.conn.Close(); //刷新视图 otherMTypeImport(mtypeID, nameOfOtherRem); } } } catch (Exception exc) { throw exc; } finally { login.conn.Close(); } }; #endregion #region 添加列 NColumn += (object o, EventArgs ea) => { try { //选择某个日期 addDateDialog addia = new addDateDialog(); if (addia.ShowDialog() == DialogResult.OK) { if (addia.dateT != null) { //0 检查是否已经存在相同日期,若存在则抛出错误 login.conn.Open(); SqlCommand sc = new SqlCommand("select ID from fp_" + proID + "_dateRemark where dateT='" + addia.dateT.ToBinary().ToString() + "' and mtypeID='" + mtypeID + "'", login.conn); if (sc.ExecuteScalar() != null) { throw new Exception("已存在相同的日期值"); } //1 把日期插入dateRemark表并取回ID sc.CommandText = "insert into fp_" + proID + "_dateRemark(dateT,mtypeID) values('" + addia.dateT.ToBinary().ToString() + "','" + mtypeID + "')"; sc.ExecuteNonQuery(); sc.CommandText = "select @@identity"; string currentID = sc.ExecuteScalar().ToString(); //2 插入到数据表 sc.CommandText = "alter table fp_" + proID + "_" + mtypeID + " add d" + currentID + " float"; sc.ExecuteNonQuery(); //3 刷新视图 login.conn.Close(); otherMTypeImport(mtypeID, nameOfOtherRem);//这里之前若不关闭连接会导致连接重复打开 } } } catch (Exception exc) { throw exc; } finally { login.conn.Close();//即使throw出来也能关闭conn } }; #endregion #region 保存 save += (object o, EventArgs ea) => { try { if (isSave) return; login.conn.Open(); //首先保存总备注 SqlCommand sc = new SqlCommand("update fp_" + proID + "_mtype set remark='" + tb_editpro_remarks.Text + "' where ID='" + mtypeID + "'", login.conn); sc.ExecuteNonQuery(); //保存日备注及其他信息 for (int i = 2; i < dgv_editpro.Columns.Count; i++) { object cell1 = dgv_editpro.Rows[dgv_editpro.Rows.Count - 3].Cells[i].Value; object cell2 = dgv_editpro.Rows[dgv_editpro.Rows.Count - 2].Cells[i].Value; object cell3 = dgv_editpro.Rows[dgv_editpro.Rows.Count - 1].Cells[i].Value; if (cell1 == null) cell1 = ""; if (cell2 == null) cell2 = ""; if (cell3 == null) cell3 = ""; sc.CommandText = "update fp_" + proID + "_dateRemark set remark='" + cell1.ToString() + "',condition='" + cell2.ToString() + "',otherRem='" + cell3.ToString() + "' where dateT='" + DateTime.Parse(dgv_editpro.Columns[i].HeaderText).ToBinary().ToString() + "' and mtypeID='" + mtypeID + "'"; sc.ExecuteNonQuery(); } //保存数据 for (int i = 0; i < dgv_editpro.Rows.Count - 3; i++) { sc.CommandText = "update fp_" + proID + "_" + mtypeID + " set "; //组建命令 for (int j = 2; j < dgv_editpro.Columns.Count; j++) { if (j == 2) { sc.CommandText += dgv_editpro.Columns[j].Name + "='" + dgv_editpro.Rows[i].Cells[j].Value.ToString() + "'"; continue; } sc.CommandText += "," + dgv_editpro.Columns[j].Name + "='" + dgv_editpro.Rows[i].Cells[j].Value.ToString() + "'"; } sc.CommandText += " where ID='" + dgv_editpro.Rows[i].Cells[0].Value.ToString() + "'"; sc.ExecuteNonQuery(); } //刷新视图 //login.conn.Close(); //otherMTypeImport(mtypeID, nameOfOtherRem); setSaveState(true); } catch (Exception exc) { throw exc; } finally { login.conn.Close(); } }; #endregion #region 删除行 DLine += (object o, EventArgs ea) => { try { login.conn.Open(); SqlCommand sc = new SqlCommand(); sc.Connection = login.conn; List<int> rowindices = new List<int>();//用于存储选中的行index for (int i = 0; i < dgv_editpro.SelectedCells.Count; i++) { rowindices.Add(dgv_editpro.SelectedCells[i].RowIndex); } //清除多余的index var tempIndices = rowindices.Distinct().Where(n => n < dgv_editpro.Rows.Count - 3); //删除每一行 if (tempIndices.Count() > 0) { foreach (var n in tempIndices) { sc.CommandText = "delete from fp_" + proID + "_" + mtypeID + " where ID='" + dgv_editpro.Rows[n].Cells[0].Value.ToString() + "'"; sc.ExecuteNonQuery(); //从视图中移除该行 dgv_editpro.Rows.RemoveAt(n); } //刷新视图 //login.conn.Close(); //otherMTypeImport(mtypeID, nameOfOtherRem); } } catch (Exception exc) { throw exc; } finally { login.conn.Close(); } }; #endregion #region 删除列 DColumn += (object o, EventArgs ea) => { try { login.conn.Open(); SqlCommand sc = new SqlCommand(); sc.Connection = login.conn; List<int> columnsIndices = new List<int>();//用于存储选中的列index for (int i = 0; i < dgv_editpro.SelectedCells.Count; i++) { columnsIndices.Add(dgv_editpro.SelectedCells[i].ColumnIndex); } //清除多余的index var tempIndices = columnsIndices.Distinct().Where(n => n > 1); //删除每一列 if (tempIndices.Count() > 0) { foreach (var n in tempIndices) { //从数据表中移除 sc.CommandText = "alter table fp_" + proID + "_" + mtypeID + " drop column " + dgv_editpro.Columns[n].Name; sc.ExecuteNonQuery(); //从日期表中移除 sc.CommandText = "delete from fp_" + proID + "_dateRemark where ID='" + dgv_editpro.Columns[n].Name.Substring(1) + "'"; sc.ExecuteNonQuery(); //从视图中移除该列 dgv_editpro.Columns.Remove(dgv_editpro.Columns[n].Name); } //刷新视图 //login.conn.Close(); //otherMTypeImport(mtypeID, nameOfOtherRem); } } catch (Exception exc) { throw exc; } finally { login.conn.Close(); } }; #endregion }
/// <summary> /// 测孔位移录入 /// </summary> private void 测孔位移HToolStripMenuItem_Click(object sender, EventArgs e) { prepareForEdit(true, true, "本类别备注", true, true, true, true, true, true, true, true, editType.holesD, "测孔位移录入"); Dictionary<string, int> ptList = new Dictionary<string, int>();//点位名-汇总表ID 字典 #region 读入数据 try { //1 读入已有测孔位移坐标,并组建 点位名-汇总表ID 字典,用于选择某个点位后检索数据 login.conn.Open(); SqlCommand sc = new SqlCommand("select fp_@proID_0.ID,pName from fp_@proID_PT,fp_@proID_0 where pID=fp_@proID_PT.ID", login.conn); sc.CommandText = sc.CommandText.Replace("@proID", proID); SqlDataReader sdr = sc.ExecuteReader(); while (sdr.Read()) { ptList.Add(sdr.GetString(1), sdr.GetInt32(0)); //把坐标名添加到选择列表 tscb_editpro_extraList.Items.Add(sdr.GetString(1)); } sdr.Close(); tscb_editpro_extraList.Text = "请选择某个坐标"; //2 读入总备注 sc.CommandText = "select remark from fp_" + proID + "_mtype where ID='0'"; tb_editpro_remarks.Text = sc.ExecuteScalar().ToString();//这里修改了输入框的值,会触发输入框被更改事件,从而把保存状态改为false,下面要重新改正 setSaveState(true); } catch (Exception exc) { throw exc; } finally { login.conn.Close(); } #endregion #region 添加新斜测孔坐标 AddPT += (object o, EventArgs ea) => { try { AddPTDialog apd = new AddPTDialog(proID); if (apd.ShowDialog() == DialogResult.OK) { if (apd.pID != -1) { login.conn.Open(); //1 添加到汇总坐标中 SqlCommand sc = new SqlCommand("insert into fp_" + proID + "_0(pID) values('" + apd.pID.ToString() + "')", login.conn); sc.ExecuteNonQuery(); //2 为该坐标创建数据表 sc.CommandText = "select @@identity"; int ID = Convert.ToInt32(sc.ExecuteScalar()); sc.CommandText = "create table fp_" + proID + "_0_" + ID.ToString() + "(ID int identity(0,1) primary key,dep float not null unique)"; sc.ExecuteNonQuery(); //3 添加到 点位名-汇总表ID 字典 ptList.Add(apd.pName, ID); //4 添加到视图点位列表 tscb_editpro_extraList.Items.Add(apd.pName); } } } catch (Exception exc) { throw exc; } finally { login.conn.Close(); } }; #endregion #region 根据选择的坐标读取数据 extraList_SelectedIndexChanged += (object o, EventArgs ea) => { try { login.conn.Open(); Dictionary<int, long> dateList = new Dictionary<int, long>();//日期列表 //清空视图 dgv_editpro.Columns.Clear(); //1 设置表格样式 dgv_editpro.Columns.Add(new DataGridViewTextBoxColumn() { Name = "ID", HeaderText = "ID", ReadOnly = true, DefaultCellStyle = new DataGridViewCellStyle() { BackColor = Color.Gray } }); dgv_editpro.Columns.Add("dep", "深度"); //2 读取日期列表,用于排序 SqlCommand sc = new SqlCommand("select ID,dateT from fp_" + proID + "_dateRemark", login.conn); SqlDataReader sdr = sc.ExecuteReader(); while (sdr.Read()) { dateList.Add(sdr.GetInt32(0), sdr.GetInt64(1)); } sdr.Close(); //3 读出该坐标的所有数据 DataTable dt = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter("select * from fp_" + proID + "_0_" + ptList[tscb_editpro_extraList.SelectedItem.ToString()].ToString() + " order by dep DESC", login.conn); sda.Fill(dt); //4 对列名日期排序,得到排序后的新表 DataTable sortedDt = null;//排序后的新表 if (dt.Columns.Count > 2) { //列名-日期值字典 Dictionary<string, long> columnDateT = new Dictionary<string, long>(); for (int i = 2; i < dt.Columns.Count; i++) { columnDateT.Add(dt.Columns[i].ColumnName, dateList[Convert.ToInt32(dt.Columns[i].ColumnName.Substring(1))]); } //排序 var sortedColumnDateT = columnDateT.OrderBy(n => n.Value); //组出新的列名 List<string> columnNames = new List<string>(); columnNames.Add("ID"); columnNames.Add("dep"); foreach (var n in sortedColumnDateT) { columnNames.Add(n.Key); //顺便添加到视图 dgv_editpro.Columns.Add(n.Key, DateTime.FromBinary(n.Value).ToString()); } //组建新表 sortedDt = dt.DefaultView.ToTable(false, columnNames.ToArray()); } //锁定列,防止排序 for (int i = 0; i < dgv_editpro.Columns.Count; i++) { dgv_editpro.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } DataTable finalDT = sortedDt == null ? dt : sortedDt; //写入数据 foreach (DataRow row in finalDT.Rows) { dgv_editpro.Rows.Add(row.ItemArray);//这里的操作使读出的空值变为0 } } catch (Exception exc) { throw exc; } finally { login.conn.Close(); } }; #endregion #region 添加新行 NLine += (object o, EventArgs ea) => { try { if (tscb_editpro_extraList.SelectedItem == null) { throw new Exception("请选择一个坐标"); } string dep = inputBox("请输入深度值"); if (dep != null && dep != "") { login.conn.Open(); SqlCommand sc = new SqlCommand(); sc.Connection = login.conn; //匹配数字 Regex rx = new Regex(@"^\-?\d+(\.\d+)?$"); if (rx.IsMatch(dep)) { sc.CommandText = "insert into fp_" + proID + "_0_" + ptList[tscb_editpro_extraList.SelectedItem.ToString()].ToString() + "(dep) values('" + dep + "')"; sc.ExecuteNonQuery(); login.conn.Close(); //刷新视图 extraList_SelectedIndexChanged(sender, e); } else { //匹配快速输入模式 start:end:step rx = new Regex(@"^(?<start>\-?\d+(\.\d+)?)\:(?<end>\-?\d+(\.\d+)?)\:(?<step>\-?\d+(\.\d+)?)$"); Match m = rx.Match(dep); if (m.Success) { GroupCollection gc = m.Groups; double start = Convert.ToDouble(gc["start"].Value); double end = Convert.ToDouble(gc["end"].Value); double step = Convert.ToDouble(gc["step"].Value); double temp; //如果start比end大,交换之 if (start > end) { temp = start; start = end; end = temp; } //如果step<0,取正 if (step < 0) step = -step; for (double i = start; i <= end; i += step) { sc.CommandText = "insert into fp_" + proID + "_0_" + ptList[tscb_editpro_extraList.SelectedItem.ToString()].ToString() + "(dep) values('" + i.ToString() + "')"; sc.ExecuteNonQuery(); } login.conn.Close(); //刷新视图 extraList_SelectedIndexChanged(o, ea); } else { throw new Exception("请输入正确的数值格式!"); } } } } catch (Exception exc) { MessageBox.Show(exc.Message); } finally { login.conn.Close(); } }; #endregion #region 添加新列 NColumn += (object o, EventArgs ea) => { try { if (tscb_editpro_extraList.SelectedItem == null) { throw new Exception("请选择一个坐标"); } //取得要添加的日期 addDateDialog addia = new addDateDialog(); if (addia.ShowDialog() == DialogResult.OK) { if (addia.dateT != null) { login.conn.Open(); //1 插入到日期表 SqlCommand sc = new SqlCommand("insert into fp_" + proID + "_dateRemark(dateT,mtypeID) values('" + addia.dateT.ToBinary().ToString() + "','0')", login.conn); sc.ExecuteNonQuery(); //2 取回插入ID sc.CommandText = "select @@identity"; string ID = sc.ExecuteScalar().ToString(); //3 添加该日期列,列名格式为 d+日期ID sc.CommandText = "alter table fp_" + proID + "_0_" + ptList[tscb_editpro_extraList.SelectedItem.ToString()].ToString() + " add d" + ID + " float"; sc.ExecuteNonQuery(); //刷新视图 login.conn.Close(); extraList_SelectedIndexChanged(o, ea); } } } catch (Exception exc) { MessageBox.Show(exc.Message); } finally { login.conn.Close(); } }; #endregion #region 保存 save += (object o, EventArgs ea) => { if (isSave) return; try { login.conn.Open(); //先保存总备注 SqlCommand sc = new SqlCommand("update fp_" + proID + "_mtype set remark='" + tb_editpro_remarks.Text + "' where ID='0'", login.conn); sc.ExecuteNonQuery(); //如果有选择某个坐标才进行坐标保存 if (tscb_editpro_extraList.SelectedItem != null) { //仅保存被修改的行 foreach (editedCell ec in editedCells) { sc.CommandText = "update fp_" + proID + "_0_" + ptList[tscb_editpro_extraList.SelectedItem.ToString()].ToString() + " set dep='" + dgv_editpro.Rows[ec.X].Cells[1].Value.ToString() + "'"; for (int j = 2; j < dgv_editpro.Columns.Count; j++) { sc.CommandText += "," + dgv_editpro.Columns[j].Name + "='" + dgv_editpro.Rows[ec.X].Cells[j].Value.ToString() + "'"; } sc.CommandText += " where ID='" + ec.ID + "'"; sc.ExecuteNonQuery(); } } setSaveState(true); } catch (Exception exc) { MessageBox.Show(exc.Message); } finally { login.conn.Close(); } }; #endregion #region 删除点位 DelPT += (object o, EventArgs ea) => { if (tscb_editpro_extraList.SelectedIndex != -1) { if (MessageBox.Show("是否真的要删除该测斜孔坐标?", "删除", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { try { login.conn.Open(); string selectedPtID = ptList[tscb_editpro_extraList.SelectedItem.ToString()].ToString(); //0 移除该坐标点所有的相关日期项 SqlCommand sc = new SqlCommand(); sc.Connection = login.conn; for (int i = 2; i < dgv_editpro.Columns.Count; i++) { sc.CommandText = "delete from fp_" + proID + "_dateRemark where ID='" + dgv_editpro.Columns[i].Name.Substring(1) + "'"; sc.ExecuteNonQuery(); } //1 移除数据表 sc.CommandText = "drop table fp_" + proID + "_0_" + selectedPtID; sc.ExecuteNonQuery(); //2 在ID汇总表删除该ID行 sc.CommandText = "delete from fp_" + proID + "_0 where ID='" + selectedPtID + "'"; sc.ExecuteNonQuery(); login.conn.Close(); //刷新视图 测孔位移HToolStripMenuItem_Click(sender, e); } catch (Exception exc) { throw exc; } finally { login.conn.Close(); } } } }; #endregion #region 删除行 DLine += (object o, EventArgs ea) => { try { login.conn.Open(); SqlCommand sc = new SqlCommand(); sc.Connection = login.conn; List<int> rowindices = new List<int>();//用于存储选中的行index for (int i = 0; i < dgv_editpro.SelectedCells.Count; i++) { rowindices.Add(dgv_editpro.SelectedCells[i].RowIndex); } //清除多余的index var tempIndices = rowindices.Distinct(); //删除每一行 if (tempIndices.Count() > 0) { foreach (var n in tempIndices) { sc.CommandText = "delete from fp_" + proID + "_0_" + ptList[tscb_editpro_extraList.SelectedItem.ToString()].ToString() + " where ID=" + dgv_editpro.Rows[n].Cells[0].Value.ToString(); sc.ExecuteNonQuery(); //移除视图中的行 dgv_editpro.Rows.RemoveAt(n); } //刷新视图 //login.conn.Close(); } } catch (Exception exc) { throw exc; } finally { login.conn.Close(); } }; #endregion #region 删除列 DColumn += (object o, EventArgs ea) => { List<string> selectedColumnIndices = new List<string>(); foreach (DataGridViewCell cell in dgv_editpro.SelectedCells) { selectedColumnIndices.Add(cell.OwningColumn.Name); } //取得唯一值 var tempV = selectedColumnIndices.Distinct(); //开始删除列 try { login.conn.Open(); SqlCommand sc = new SqlCommand(); sc.Connection = login.conn; foreach (var columnName in tempV) { //排除前两列 if (columnName != "ID" && columnName != "dep") { //删除数据表中的列 sc.CommandText = "alter table fp_" + proID + "_0_" + ptList[tscb_editpro_extraList.SelectedItem.ToString()].ToString() + " drop column " + columnName; sc.ExecuteNonQuery(); //移除日期表中的项 sc.CommandText = "delete from fp_" + proID + "_dateRemark where ID='" + Convert.ToInt32(columnName.Substring(1)).ToString() + "'"; sc.ExecuteNonQuery(); //删除视图的列 dgv_editpro.Columns.Remove(columnName); } } //login.conn.Close(); //刷新视图 //extraList_SelectedIndexChanged(o, ea); } catch (Exception exc) { throw exc; } finally { login.conn.Close(); } }; #endregion }