public int Insert(EDIT e) { using (SqlConnection conn = new SqlConnection(connstring)) { conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = string.Format("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;SELECT MAX(E_SYSID) FROM T_EDIT WHERE SUBSTRING(E_SYSID,1,8)='{0}';", DateTime.Now.ToString("yyyyMMdd")); string e_sysid = string.Empty; e_sysid = cmd.ExecuteScalar().ToString(); if (string.IsNullOrEmpty(e_sysid)) { e_sysid = DateTime.Now.ToString("yyyyMMdd") + "7000001"; } else { e_sysid = (Convert.ToInt64(e_sysid) + 1).ToString(); } cmd.CommandText = string.Format(@"INSERT INTO T_EDIT (E_SYSID,E_TITLE,E_EDITOR,E_CONTENT,E_DATETIME,E_TITLEPIC) VALUES ('{0}',N'{1}',N'{2}',N'{3}','{4}',N'{5}')", e_sysid, e.E_TITLE, e.E_EDITOR, e.E_CONTENT, e.E_DATETIME, e.E_TITLEPIC); return(cmd.ExecuteNonQuery()); } } }
void InitConstruct() { RUNSPEC runspec = new RUNSPEC("RUNSPEC"); this.Key.Add(runspec); GRID grid = new GRID("GRID"); this.Key.Add(grid); EDIT edit = new EDIT("EDIT"); this.Key.Add(edit); PROPS props = new PROPS("PROPS"); this.Key.Add(props); REGIONS regions = new REGIONS("REGIONS"); this.Key.Add(regions); SOLUTION solution = new SOLUTION("SOLUTION"); this.Key.Add(solution); SUMMARY summary = new SUMMARY("SUMMARY"); this.Key.Add(summary); SCHEDULE schedule = new SCHEDULE("SCHEDULE"); this.Key.Add(schedule); }
public int Update(EDIT e) { using (SqlConnection conn = new SqlConnection(connstring)) { conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = string.Format(@"UPDATE T_EDIT SET E_TITLE=N'{0}',E_EDITOR=N'{1}',E_CONTENT=N'{2}',E_DATETIME='{3}',E_TITLEPIC=N'{4}' WHERE E_SYSID='{5}' AND E_ISDEL='1' ", e.E_TITLE, e.E_EDITOR, e.E_CONTENT, e.E_DATETIME, e.E_TITLEPIC, e.E_SYSID); return(cmd.ExecuteNonQuery()); } } }
public List <EDIT> DataToEdit(DataTable dt) { List <EDIT> list = new List <EDIT>(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { EDIT d = new EDIT { E_SYSID = dt.Rows[i]["E_SYSID"].ToString(), E_CONTENT = dt.Rows[i]["E_CONTENT"].ToString(), E_TITLE = dt.Rows[i]["E_TITLE"].ToString(), E_EDITOR = dt.Rows[i]["E_EDITOR"].ToString(), E_DATETIME = dt.Rows[i]["E_DATETIME"].ToString(), E_ISDEL = dt.Rows[i]["E_ISDEL"].ToString(), NUM = dt.Rows[i]["NUM"].ToString(), E_TITLEPIC = dt.Rows[i]["E_TITLEPIC"].ToString() }; list.Add(d); } } return(list); }
public Prim3(string path, string text) { InitializeComponent(); BD.path = path; //укажем файл бд this.text_otvet = text.Trim(); //PRIM=a2131231232321;AVTO=asdasdasda // MessageBox.Show(this.text_otvet); if (text_otvet.Contains("PRIM=") && text_otvet.Contains(";AVTO=") && text_otvet.Contains(";EDIT=")) { try { PRIM = (text_otvet.Split(';'))[0].Substring(5); } catch { PRIM = ""; } try { AUTO = (text_otvet.Split(';'))[1].Substring(5).Trim('^'); } catch { AUTO = ""; } try { EDIT = (text_otvet.Split(';'))[2].Substring(5); } catch { EDIT = "0"; } try { SAUTO = (text_otvet.Split(';'))[3].Substring(6).Trim('^'); } catch { SAUTO = ""; } } else { PRIM = text_otvet; AUTO = ""; SAUTO = ""; EDIT = "0"; } // if (EDIT.Equals("1")) { tb3.IsEnabled = true; cb1.IsChecked = true; } else { tb3.IsEnabled = false; cb1.IsChecked = false; } OleDbDataReader reader = BD.conn("SELECT STCommentD.Name, STCommentD.ID, STCommentDchasto.Chastota FROM STCommentD LEFT JOIN STCommentDchasto ON STCommentD.ID = STCommentDchasto.IDComment ORDER BY STCommentDchasto.Chastota DESC"); while (reader.Read()) { int Chasto = 0; if (reader["Chastota"].ToString() != "") { Chasto = Convert.ToInt32(reader["Chastota"]); } result.Add(new MyTable() { ID = reader["ID"].ToString(), Name = reader["Name"].ToString(), Chasto = Chasto }); } reader.Close(); loadpage(); //загрузка полож окна proverka_uhoda_za_granicu(); //проверка ухода за границу tb2.Focus(); string t = PRIM.Replace('#', '"').Replace('$', ';').Replace('@', ',').Replace('№', '/').Replace('^', ' ').Replace('|', ';'); tb1.Text = t; tb3.Text = AUTO; if (!AUTO.Equals("")) { string[] split_AUTO = AUTO.Split('^'); foreach (string elem in split_AUTO) { var splitelemrech = elem.Split('#'); btn_spis elemnew; if (splitelemrech.Length == 2) { elemnew = new btn_spis() { name = splitelemrech[1].Trim(), id = splitelemrech[0].Trim() }; } else { elemnew = new btn_spis() { name = elem.Trim() }; } /* * string[] splitenable = elem.Split('#'); * var elemnew = new btn_spis() { * name = splitenable[0], * vibran = splitenable.Length==2? splitenable[1]=="1":true * };*/ spisbtn.Add(elemnew); lbbutton.Items.Add(elemnew); } } // MessageBox.Show(SAUTO); if (!SAUTO.Equals("")) { string[] split_SAUTO = SAUTO.Split('^'); foreach (string elem in split_SAUTO) { // var elemnew = new btn_spis() { name = elem.Trim() }; var splitelemrech = elem.Split('#'); var elemnew = new btn_spis() { name = splitelemrech[1].Trim(), id = splitelemrech[0].Trim() }; /* * string[] splitenable = elem.Split('#'); * var elemnew = new btn_spis() { * name = splitenable[0], * vibran = splitenable.Length==2? splitenable[1]=="1":true * };*/ var findelem = spisbtn.Find(x => x.id == elemnew.id); if (findelem != null) { // MessageBox.Show(findelem.name +" "+ elemnew.name); if (findelem.name.Trim().ToLower() == elemnew.name.Trim().ToLower()) //просто крести { findelem.setvibran(false); //показываес что элемент крестик } else //крестик и указываем что изменен1 { findelem.setvibran(false, true); //показываес что элемент крестик lvstalo.Items.Add(new bilostalo() { bilo = elemnew.name, stalo = findelem.name, deystvie = "Изменено", colorbg = "#66FFF500" }); // bilo.Items.Add(elemnew); // stalo.Items.Add(findelem); spisbtnSAUTO.Add(elemnew); } } else { logdlas += elemnew.name + " - АВТОПРИМЕЧАНИЕ УДАЛЕНО" + Environment.NewLine; spisbtnSAUTO.Add(elemnew); lvstalo.Items.Add(new bilostalo() { bilo = elemnew.name, stalo = "", deystvie = "Удалено", colorbg = "#66FF0000" }); // bilo.Items.Add(elemnew); // stalo.Items.Add(null); } // lbbutton.Items.Add(elemnew); } } if (spisbtnSAUTO.Count == 0) { ddddd.Height = new GridLength(0); } // tbizmen.Text= logdlas; tb1.CaretIndex = tb1.Text.Length; }
/// <summary> 清理父节点 </summary> public void InitParentKey() { RUNSPEC runspec = this.Key.CreateSingle <RUNSPEC>("RUNSPEC"); GRID grid = this.Key.CreateSingle <GRID>("GRID"); if (grid != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_grid.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; grid.Add(include); INCLUDE include1 = new INCLUDE("INCLUDE"); include1.FileName = this.FileName.GetFileNameWithoutExtension() + "_faults.inc"; include1.FilePath = this.FilePath.GetDirectoryName() + "\\" + include1.FileName; grid.Add(include1); INCLUDE include2 = new INCLUDE("INCLUDE"); include2.FileName = this.FileName.GetFileNameWithoutExtension() + "_aquifer.inc"; include2.FilePath = this.FilePath.GetDirectoryName() + "\\" + include1.FileName; grid.Add(include2); } EDIT edit = this.Key.Find <EDIT>(); if (edit != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_edit.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; edit.Add(include); } PROPS props = this.Key.CreateSingle <PROPS>("PROPS"); if (props != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_pvt.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; props.Add(include); include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_rp.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; props.Add(include); } SOLUTION solution = this.Key.CreateSingle <SOLUTION>("SOLUTION"); if (solution != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_init.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; solution.Add(include); } REGIONS region = this.Key.CreateSingle <REGIONS>("REGIONS"); if (region != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_regs.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; region.Add(include); } SUMMARY summary = this.Key.CreateSingle <SUMMARY>("SUMMARY"); if (summary != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_sum.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; summary.Add(include); //if (include.Keys.Count == 0) //{ // ALL all = new ALL("ALL"); // include.Add(all); //} } SCHEDULE schedule = this.Key.CreateSingle <SCHEDULE>("SCHEDULE"); if (schedule != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_sch.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; schedule.Add(include); } END end = this.Key.CreateSingle <END>("END"); }
public Prim2(string path, string text) { InitializeComponent(); BD.path = path; //укажем файл бд this.text_otvet = text.Trim(); // MessageBox.Show(this.text_otvet); //PRIM=a2131231232321;AVTO=asdasdasda// if (text_otvet.Contains("PRIM=") && text_otvet.Contains(";AVTO=") && text_otvet.Contains(";EDIT=")) { try { PRIM = (text_otvet.Split(';'))[0].Substring(5); } catch { PRIM = ""; } try { AUTO = (text_otvet.Split(';'))[1].Substring(5).Trim('^'); } catch { AUTO = ""; } try { EDIT = (text_otvet.Split(';'))[2].Substring(5); } catch { EDIT = "0"; } } else { PRIM = text_otvet; AUTO = ""; EDIT = "0"; } if (EDIT.Equals("1")) { tb3.IsEnabled = true; cb1.IsChecked = true; } else { tb3.IsEnabled = false; cb1.IsChecked = false; } OleDbDataReader reader = BD.conn("SELECT STCommentD.Name, STCommentD.ID, STCommentDchasto.Chastota FROM STCommentD LEFT JOIN STCommentDchasto ON STCommentD.ID = STCommentDchasto.IDComment ORDER BY STCommentDchasto.Chastota DESC"); while (reader.Read()) { int Chasto = 0; if (reader["Chastota"].ToString() != "") { Chasto = Convert.ToInt32(reader["Chastota"]); } result.Add(new MyTable() { ID = reader["ID"].ToString(), Name = reader["Name"].ToString(), Chasto = Chasto }); } loadpage(); //загрузка полож окна proverka_uhoda_za_granicu(); //проверка ухода за границу tb2.Focus(); string t = PRIM.Replace('#', '"').Replace('$', ';').Replace('@', ',').Replace('№', '/').Replace('^', ' ').Replace('|', ';'); tb1.Text = t; tb3.Text = AUTO; if (!AUTO.Equals("")) { string[] split_AUTO = AUTO.Split('^'); foreach (string elem in split_AUTO) { var splitelemrech = elem.Split('#'); var elemnew = new btn_spis() { name = splitelemrech.Length == 2? splitelemrech [1]: elem }; spisbtn.Add(elemnew); lbbutton.Items.Add(elemnew); } } // lbbutton.ItemsSource = spisbtn; tb1.CaretIndex = tb1.Text.Length; }