public void DeleteData(String num) { JTable tab1 = new JTable(); tab1.MyConnect.BeginTrans(); try { List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("parentnum", num, SearchFieldType.NumericType)); tab1.TableName = "BIGSTATIONLIST"; tab1.DeleteData(condition); tab1.TableName = "BIGSTATION"; condition.Clear(); condition.Add(new SearchField("num", num, SearchFieldType.NumericType)); tab1.DeleteData(condition); tab1.MyConnect.CommitTrans(); } catch { tab1.MyConnect.RollBackTrans(); } finally { if (tab1 != null) { tab1.Close(); } } }
//删除数据 public void DeleteData(String LineID) { JTable tab1 = new JTable(); List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("LineId", LineID, SearchFieldType.NumericType)); tab1.TableName = "CHANGJIAOQYFEE"; tab1.DeleteData(condition); tab1.TableName = "CHANGJIAOQYFEECHILD"; tab1.DeleteData(condition); tab1.Close(); }
/// <summary> /// 根据条件删除数据 /// </summary> /// <param name="condition">删除数据条件</param> public void DeleteData(List <SearchField> condition) { JTable tab1 = new JTable(daConnect, TableName); tab1.DeleteData(condition); tab1.Close(); }
public static void SetBigList(String num, String bigList) { if (String.IsNullOrEmpty(bigList) == false && String.IsNullOrEmpty(num) == false) { String[] str1 = bigList.Replace(",", ",").Split(','); JTable tab1 = new JTable("BIGSTATIONLIST"); List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("parentnum", num, SearchFieldType.NumericType)); tab1.DeleteData(condition); DataSet ds1 = tab1.SearchData(condition, -1, "*"); int i = 1; bool isEdit = false; foreach (String m in str1) { if (isEdit == false) { isEdit = true; } DataRow dr1 = ds1.Tables[0].NewRow(); dr1["num"] = i; dr1["parentnum"] = num; dr1["name1"] = m; i++; ds1.Tables[0].Rows.Add(dr1); } if (isEdit) { tab1.Update(ds1.Tables[0]); } tab1.Close(); } }
//更新列表数据 public static void UpdateListData(DataTable dt1) { JTable tab1 = new JTable("TrainPerson"); tab1.MyConnect.BeginTrans(); try { List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("1=1", "", SearchOperator.UserDefine)); tab1.DeleteData(condition); //插入新的数据 Dictionary <String, object> data1 = new Dictionary <string, object>(); foreach (DataRow dr1 in dt1.Rows) { int pcount = int.Parse(dr1["pcount"].ToString()); if (pcount > 0) { data1.Clear(); data1["traintype"] = dr1["traintype"]; data1["kind"] = dr1["kind"]; data1["gw"] = dr1["gw"]; data1["pcount"] = dr1["pcount"]; tab1.InsertData(data1); } } tab1.MyConnect.CommitTrans(); } catch { tab1.MyConnect.RollBackTrans(); } tab1.Close(); }
/// <summary> /// 根据条件删除数据 /// </summary> /// <param name="condition">删除数据条件</param> public void DeleteData(List <SearchField> condition) { JTable tab1 = new JTable(daConnect, TableName); tab1.DeleteData(condition); this.executeResultCount = tab1.ExecuteResultCount; tab1.Close(); }
void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { String userid = e.CommandArgument.ToString(); if (String.IsNullOrEmpty(userid) == false) { JTable tab1 = new JTable("MYUSERNAME"); List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("UserName", userid)); tab1.DeleteData(condition); tab1.Close(); //更新角色中的相关数据 JTable tab2 = new JTable(); tab2.TableName = "JROLEUSERS"; condition.Clear(); condition.Add(new SearchField("RoleID", "001")); condition.Add(new SearchField("UserID", userid)); tab2.DeleteData(condition); tab2.Close(); this.Repeater1.DataBind(); } }
/// <summary> /// 将列车的电费和接触网使用费导入到系统中 /// </summary> public static void ImportTrainDianFeeToSystem(String FileName, bool Append) { JTable tab1 = new JTable("NewTrainDianFee"); Dictionary <String, object> data1 = new Dictionary <string, object>(); String FileName1 = HttpContext.Current.Server.MapPath("~/Attachment/" + FileName); if (File.Exists(FileName1)) { DataSet ds1 = PubCode.Util.xsldata(FileName1, "Table1"); if (ds1 != null && ds1.Tables[0].Rows.Count > 0) { String[] fs1 = new String[] { "TRAINNAME", "ASTATION", "BSTATION", "ZL1", "ZL2", "ZL3", "Fee1", "Fee2", "Fee3" }; int[] col = new int[] { 0, 1, 2, 3, 4, 5, 7, 8, 9 }; int index = 0; int year = DateTime.Now.Year; int month = DateTime.Now.Month; foreach (DataRow dr1 in ds1.Tables[0].Rows) { if (index == 0) { String str1 = dr1[4].ToString().Replace("-", "-"); //清算日期:2011年12月01日-2011年12月31日 String str0 = str1.Split('-')[1]; DateTime time0 = DateTime.Parse(str0); year = time0.Year; month = time0.Month; //删除以前的老数据 if (Append == false) { List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("byear", year + "", SearchFieldType.NumericType)); condition.Add(new SearchField("bmonth", month + "", SearchFieldType.NumericType)); JTable tab2 = new JTable("NewTrainDianFee"); tab2.DeleteData(condition); tab2.Close(); } } if (index >= 2) //开始导入数据 { if (dr1[0].ToString() != String.Empty && dr1[0].ToString() != "合计" && dr1[1].ToString() != String.Empty && dr1[2].ToString() != String.Empty) { data1.Clear(); for (int i = 0; i < fs1.Length; i++) { data1[fs1[i]] = dr1[col[i]]; } if (data1.Count > 0) { data1["byear"] = year; data1["bmonth"] = month; for (int j = 3; j <= 8; j++) { data1[fs1[j]] = data1[fs1[j]].ToString().Replace(",", ""); if (data1[fs1[j]].ToString().Trim() == "-") { data1[fs1[j]] = "0"; } } tab1.InsertData(data1); } } } index++; } } } tab1.Close(); }
/// <summary> /// 将列车的收入数据导入到系统中 /// </summary> public static void ImportTrainShouRouDataToSystem(String FileName, bool Append) { JTable tab1 = new JTable("NEWTRAINSHOUROU"); Dictionary <String, object> data1 = new Dictionary <string, object>(); String FileName1 = HttpContext.Current.Server.MapPath("~/Attachment/" + FileName); if (File.Exists(FileName1)) { DataSet ds1 = PubCode.Util.xsldata(FileName1, "Table1"); if (ds1 != null && ds1.Tables[0].Rows.Count > 0) { String[] fs1 = new String[] { "TRAINNAME", "ASTATION", "BSTATION", "SHOUROU1", "SHOUROU2", "SHOUROU3", "SHOUROU4", "SHOUROU5", "SHOUROU6" }; String[] fs2 = new String[] { "YinZuo", "RuanZuo", "OpenYinWo", "CloseYinWo", "RuanWo", "AdvanceRuanWo", "CanChe", "FaDianChe", "ShuYinChe", "YouZhengChe" }; int index = 0; int year = DateTime.Now.Year; int month = DateTime.Now.Month; DataSet oldData = null; //表示以前的老数据 String[] vArr = new String[] { "SHOUROU1", "SHOUROU2", "SHOUROU3", "SHOUROU4", "SHOUROU5", "SHOUROU6" }; JTable tab2 = new JTable("NEWTRAINSHOUROU"); foreach (DataRow dr1 in ds1.Tables[0].Rows) { if (index == 0) { String str1 = dr1[3].ToString().Replace("-", "-"); //清算日期:2011年12月01日-2011年12月31日 String str0 = str1.Split('-')[1]; DateTime time0 = DateTime.Parse(str0); year = time0.Year; month = time0.Month; //删除以前的老数据 List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("byear", year + "", SearchFieldType.NumericType)); condition.Add(new SearchField("bmonth", month + "", SearchFieldType.NumericType)); if (Append == false) { tab2.DeleteData(condition); //删除以前的数据 } oldData = tab2.SearchData(condition, -1, "*"); } if (index >= 2) //开始导入数据 { if (dr1[0].ToString() != String.Empty && dr1[0].ToString() != "合计" && dr1[1].ToString() != String.Empty && dr1[2].ToString() != String.Empty) { //导入新数据 int col = 0; data1.Clear(); foreach (String m in fs1) { data1[m] = dr1[col]; col++; } if (data1.Count > 0) { data1["byear"] = year; data1["bmonth"] = month; data1["SHOUROU1"] = data1["SHOUROU1"].ToString().Replace(",", ""); data1["SHOUROU2"] = data1["SHOUROU2"].ToString().Replace(",", ""); data1["SHOUROU3"] = data1["SHOUROU3"].ToString().Replace(",", ""); data1["SHOUROU4"] = data1["SHOUROU4"].ToString().Replace(",", ""); data1["SHOUROU5"] = data1["SHOUROU5"].ToString().Replace(",", ""); data1["SHOUROU6"] = data1["SHOUROU6"].ToString().Replace(",", ""); //得到列车默认的车厢配置数据 int[] bianzhu = GetTrainDefaultBianZhu(data1["TRAINNAME"].ToString()); for (int i = 0; i < bianzhu.Length; i++) { if (bianzhu[i] != 0) { data1[fs2[i]] = bianzhu[i]; } } String filter = "TRAINNAME='{0}' and ASTATION='{1}' and BSTATION='{2}' and byear={3} and bmonth={4}"; filter = string.Format(filter, data1["TRAINNAME"], data1["ASTATION"], data1["BSTATION"], data1["byear"], data1["bmonth"]); DataRow[] oldRows = oldData.Tables[0].Select(filter); DataRow oldRow = null; if (oldRows.Length > 0) { oldRow = oldRows[0]; foreach (String m1 in vArr) { if (oldRow[m1].ToString().Trim() == String.Empty) { if (data1[m1].ToString().Trim() != String.Empty) { oldRow[m1] = data1[m1]; } } else { if (data1[m1].ToString().Trim() != String.Empty) { oldRow[m1] = double.Parse(oldRow[m1].ToString()) + double.Parse(data1[m1].ToString()); } } } } else { oldRow = oldData.Tables[0].NewRow(); foreach (KeyValuePair <string, object> k in data1) { oldRow[k.Key] = k.Value; //新增设备 } oldData.Tables[0].Rows.Add(oldRow); } /* * if (Append == false) * { * tab1.InsertData(data1); * } * else * { * * }*/ } } } index++; } if (oldData != null) { tab2.Update(oldData.Tables[0]); } tab2.Close(); } } tab1.Close(); }
//更新长交路数据明细 private void UpdateChildData(String lineid, Dictionary <String, object> data1) { JTable tab1 = new JTable(); List <SearchField> condition = new List <SearchField>(); tab1.TableName = "CHANGJIAOQYFEECHILD"; condition.Clear(); condition.Add(new SearchField("lineid", lineid, SearchFieldType.NumericType)); tab1.DeleteData(condition); //增加新的数据 DataSet ds1 = tab1.SearchData(condition, -1, "*"); String jiaolu = data1["jiaolu"].ToString(); String[] arrJiaolu = jiaolu.Replace("~", "-").Replace("~", "-").Replace("-", "-").Split('-'); for (int i = 0; i < arrJiaolu.Length - 1; i++) { //调整字符中的分隔符。 String[] a0 = arrJiaolu[i].Trim().Replace("、", ";").Replace(",", ";").Replace(",", ";").Replace(".", ";") .Replace("(", ";").Replace(")", "").Replace("(", ";").Replace(")", "").Split(';'); String[] a1 = arrJiaolu[i + 1].Trim().Replace("、", ";").Replace(",", ";").Replace(",", ";").Replace(".", ";") .Replace("(", ";").Replace(")", "").Replace("(", ";").Replace(")", "").Split(';'); for (int j = 0; j < a0.Length; j++) { a0[j] = a0[j].Trim(); if (j > 0) { if (a0[j] == "东" || a0[j] == "南" || a0[j] == "西" || a0[j] == "北") { a0[j] = a0[j - 1] + a0[j]; } } } for (int j = 0; j < a1.Length; j++) { a1[j] = a1[j].Trim(); if (j > 0) { if (a1[j] == "东" || a1[j] == "南" || a1[j] == "西" || a1[j] == "北") { a1[j] = a1[j - 1] + a1[j]; } } } for (int j = 0; j < a0.Length; j++) { for (int k = 0; k < a1.Length; k++) { String A0 = a0[j]; String B0 = a1[k]; DataRow dr1 = ds1.Tables[0].NewRow(); dr1["lineid"] = lineid; dr1["ASTATION"] = A0; dr1["BSTATION"] = B0; dr1["fee1"] = data1["fee1"]; dr1["fee2"] = data1["fee2"]; dr1["fee3"] = data1["fee3"]; ds1.Tables[0].Rows.Add(dr1); DataRow dr2 = ds1.Tables[0].NewRow(); dr2["lineid"] = lineid; dr2["ASTATION"] = B0; dr2["BSTATION"] = A0; dr2["fee1"] = data1["fee1"]; dr2["fee2"] = data1["fee2"]; dr2["fee3"] = data1["fee3"]; ds1.Tables[0].Rows.Add(dr2); } } } //更新数据 if (ds1.Tables[0].Rows.Count > 0) { tab1.Update(ds1.Tables[0]); } }