You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using System; using System.Collections.Generic; using System.Linq; using System.Text; using ICSSoft.Frame.Data.Entity; using ICSSoft.Base.Config.DBHelper; using System.Data; using ICSSoft.Base.Config.AppConfig;
namespace ICSSoft.Frame.Data.DAL { public class ICSROUTE2OPDAL { public static void AddAndEdit(List<ICSROUTE2OP> mandayInfoList, string dsconn) {
FramDataContext db = new FramDataContext(dsconn); db.Connection.Open(); db.Transaction = db.Connection.BeginTransaction(); try { foreach (ICSROUTE2OP mandayInfo in mandayInfoList) { //todo
bool isNew = false; var line = db.ICSROUTE2OP.SingleOrDefault(a => a.ID == mandayInfo.ID); if (line == null) { isNew = true; line = new ICSROUTE2OP(); line.ID = AppConfig.GetGuid(); line.ROUTEID = mandayInfo.ROUTEID; line.OPID = mandayInfo.OPID; } line.ROUTECODE = mandayInfo.ROUTECODE; line.OPCODE = mandayInfo.OPCODE; line.OPSEQ = mandayInfo.OPSEQ; line.OPCONTROL = mandayInfo.OPCONTROL; line.CtrlType = mandayInfo.CtrlType; line.OPAttr = mandayInfo.OPAttr; line.MUSER = mandayInfo.MUSER; line.MUSERName = mandayInfo.MUSERName; line.MTIME = mandayInfo.MTIME; line.WORKPOINT = mandayInfo.WORKPOINT; if (isNew) db.ICSROUTE2OP.InsertOnSubmit(line); db.SubmitChanges(); }
db.SubmitChanges(); db.Transaction.Commit(); } catch (Exception ex) { db.Transaction.Rollback(); throw ex; } }
public static DataTable SearchROUTE2OP(string routeid, string dsconn) { List<ICSROUTE2OP> returnperson = new List<ICSROUTE2OP>(); string sql = @"select OPSEQ,OPCODE,OPID
from ICSROUTE2OP where ROUTEID='{0}' and WorkPoint='" + AppConfig.WorkPointCode + "'";
sql = string.Format(sql, routeid); DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0]; return dt; }
public static void deleteInfo(string dsconn, List<string> codeList) {
FramDataContext db = new FramDataContext(dsconn); db.Connection.Open(); db.Transaction = db.Connection.BeginTransaction(); try { var lines0 = db.ICSITEM2ROUTE.Where(a => codeList.Contains(a.ROUTEID) && a.WorkPoint == AppConfig.WorkPointCode); if (lines0.Count() != 0) { string routes = ""; List<ICSITEM2ROUTE> list = lines0.ToList(); for (int i = 0; i < list.Count(); i++) { routes += (list[i].ROUTECODE + "\r\n"); } throw new Exception(routes + "已关联产品,不可删除"); } var lines = db.ICSROUTE2OP.Where(a => codeList.Contains(a.ROUTEID) && codeList.Contains(a.OPID) && a.WORKPOINT == AppConfig.WorkPointCode); db.ICSROUTE2OP.DeleteAllOnSubmit(lines);
db.SubmitChanges(); db.Transaction.Commit(); } catch (Exception ex) { db.Transaction.Rollback(); throw ex; } finally { db.Connection.Close(); } }
public static void AddList(List<ICSROUTE2OP> list, string dsconn) { FramDataContext db = new FramDataContext(dsconn); db.Connection.Open(); db.Transaction = db.Connection.BeginTransaction(); try { foreach (ICSROUTE2OP info in list) { var line = db.ICSROUTE2OP.SingleOrDefault(a => a.ROUTEID == info.ROUTEID && a.OPID == info.OPID && a.WORKPOINT == AppConfig.WorkPointCode); if (line != null) { throw new Exception("批量添加:途程" + info.ROUTECODE + "工序" + info.OPCODE + "重复!"); } line = new ICSROUTE2OP(); line.ID = AppConfig.GetGuid(); line.ROUTEID = info.ROUTEID; line.OPID = info.OPID; line.ROUTECODE = info.ROUTECODE; line.OPCODE = info.OPCODE; line.OPSEQ = info.OPSEQ; line.OPCONTROL = info.OPCONTROL; line.CtrlType = info.CtrlType; line.OPAttr = info.OPAttr; line.MUSER = info.MUSER; line.MUSERName = info.MUSERName; line.MTIME = info.MTIME; line.WORKPOINT = info.WORKPOINT; db.ICSROUTE2OP.InsertOnSubmit(line); db.SubmitChanges(); }
db.Transaction.Commit(); } catch (Exception ex) { db.Transaction.Rollback(); throw ex; } } } }
|