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 System.Data.SqlClient; using ICSSoft.Base.Config.AppConfig; namespace ICSSoft.Frame.Data.DAL { public class ICSVendorDAL { #region AddandEdit
public static void AddandEdit(ICSVendor vendorLot, string Appconstr) { FramDataContext db = new FramDataContext(Appconstr); db.Connection.Open(); db.Transaction = db.Connection.BeginTransaction(); try { bool isNew = false; var line = db.ICSVendor.SingleOrDefault(a => a.ID == vendorLot.ID);
if (line == null) { isNew = true; line = new ICSVendor(); line.ID = AppConfig.GetGuid(); }
var codes = db.ICSVendor.Where(a => a.VendorCode == vendorLot.VendorCode && a.ID != line.ID); if (codes.ToList().Count > 0) { throw new Exception("厂商代码已存在"); }
line.VendorCode = vendorLot.VendorCode; line.VendorName = vendorLot.VendorName; line.MUSER = vendorLot.MUSER; line.MUSERName = vendorLot.MUSERName; line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss"); line.WorkPoint = AppConfig.WorkPointCode; line.EATTRIBUTE1 = null;
if (isNew) db.ICSVendor.InsertOnSubmit(line);
db.SubmitChanges(); db.Transaction.Commit(); } catch (Exception ex) { db.Transaction.Rollback(); throw new Exception(ex.Message); } } #endregion
#region select
public static ICSVendor select(String guid, String Appconstr) { FramDataContext db = new FramDataContext(Appconstr); db.Connection.Open(); db.Transaction = db.Connection.BeginTransaction(); ICSVendor entity = new ICSVendor(); try { var line = db.ICSVendor.SingleOrDefault(a => a.ID == guid); return (ICSVendor)line; } catch (Exception ex) { throw new Exception(ex.Message); } } #endregion
#region delete
public static void delete(List<String> guidList,List<string> codeList) { FramDataContext db = new FramDataContext(AppConfig.AppConnectString); db.Connection.Open(); db.Transaction = db.Connection.BeginTransaction(); try { var lines = db.ICSVendor.Where(a => guidList.Contains(a.ID)); //var line = db.ICSRES.Where(a => codeList.Contains(a.DCTCODE));
//if(line.Count()!=0){
// throw new Exception("DCT指令在资源维护已经使用,无法删除!");
//}
db.ICSVendor.DeleteAllOnSubmit(lines);
db.SubmitChanges(); db.Transaction.Commit();
} catch (Exception ex) { db.Transaction.Rollback(); throw ex; } } #endregion
} }
|