private void save() { int begin = comboBoxEdit10.SelectedIndex; int end = comboBoxEdit11.SelectedIndex; //int bh =1; if (string.IsNullOrEmpty(comboBoxEdit2.Text)) { MsgBox.ShowTipMessageBox("请选择设备种类"); comboBoxEdit2.Focus(); return; } //if (string.IsNullOrEmpty(comboBoxEdit3.Text)) { // MsgBox.ShowTipMessageBox("请选择设备型号"); // comboBoxEdit3.Focus(); // return; //} //if (!int.TryParse(comboBoxEdit1.Text, out bh)) { // bh = 1; //} //if (bh<0||bh > 999) { // MsgBox.ShowTipMessageBox("编号范围000-999"); // return; //} //if ((bh + end - begin) > 999) { // MsgBox.ShowTipMessageBox("终止编号不能大于999"); // return; //} List<PS_gtsb> gtsblist = new List<PS_gtsb>(); //for (int i = begin; i <= end; i++) { // PS_gt gt= gtlist[i].Gt; // PS_gtsb gtsb = new PS_gtsb(); // Ebada.Core.ConvertHelper.CopyTo(RowData,gtsb); // gtsb.gtID = gt.gtID; // gtsb.sbID =gt.CreateID()+i; // gtsb.sbCode = bh.ToString("000"); // gtsblist.Add(gtsb); //} DataTable dt = gridControl1.DataSource as DataTable; if (dt != null && dt.Rows.Count > 0) { for (int i = begin; i <= end; i++) { PS_gt gt = gtlist[i].Gt; int j = 0; foreach (DataRow dr in dt.Rows) { if (dr["type"] == null) continue; PS_gtsb gtsb = new PS_gtsb(); gtsb.sbName = dr["name"].ToString(); gtsb.sbModle = dr["sbgg"].ToString(); if (dr["sl"] != null && (dr["sl"].ToString().Trim())!="") gtsb.sbNumber = Convert.ToInt16( dr["sl"]); gtsb.sbID = gtsb.CreateID(); gtsb.gtID = gt.gtID; gtsb.sbID = gt.CreateID() + i; j++; gtsb.sbCode = j.ToString("000"); gtsb.sbType = dr["type"].ToString(); if (gtsb.sbName == "") continue; Thread.Sleep(new TimeSpan(100000));//0.1毫秒 gtsblist.Add(gtsb); } } } Ebada.Client.ClientHelper.PlatformSqlMap.ExecuteTransationUpdate(gtsblist, null, null); }
private void save2() { string sql = string.Format("select gtid from ps_gt where linecode in (select linecode from ps_xl where linevol='0.4' and linecode like '{0}%')", mpstq.tqCode); IList list = ClientHelper.PlatformSqlMap.GetList("SelectOneStr", sql); if (list.Count <2) return; DataTable dt = gridControl1.DataSource as DataTable; List<PS_gtsb> gtsblist = new List<PS_gtsb>(); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < list.Count; i++) { string gtid = list[i].ToString(); int j = 0; foreach (DataRow dr in dt.Rows) { if (dr["type"] == null) continue; PS_gtsb gtsb = new PS_gtsb(); gtsb.sbName = dr["name"].ToString(); gtsb.sbModle = dr["sbgg"].ToString(); if (dr["sl"] != null && (dr["sl"].ToString().Trim()) != "") gtsb.sbNumber = Convert.ToInt16(dr["sl"]); gtsb.gtID = gtid; gtsb.sbID = gtsb.CreateID() + j; j++; gtsb.sbCode = j.ToString("000"); gtsb.sbType = dr["type"].ToString(); if (gtsb.sbName == "") continue; Thread.Sleep(new TimeSpan(100000));//0.1毫秒 gtsblist.Add(gtsb); } } } if (gtsblist.Count > 0) { Ebada.Client.ClientHelper.PlatformSqlMap.ExecuteTransationUpdate(gtsblist, null, null); MsgBox.ShowTipMessageBox(string.Format("共插入{0}条记录", gtsblist.Count)); } }