public static string Copy(Guid OrgId, int DepartmentId, int MakeID, int TypeID) { using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection)) { var Makes = from t in dc.AssetMakes where t.Id == MakeID && t.DepartmentId == DepartmentId select t; var Make = Makes.FirstOrNull(); if (Make == null) { return("Can not find specified asset make."); } string MakeName = Make.Make; Makes = from t in dc.AssetMakes where t.DepartmentId == DepartmentId && t.TypeId == TypeID && t.Make == Make.Make select t; Make = Makes.FirstOrNull(); if (Make != null) { return("'" + MakeName + "' asset make exists in destination asset category. Copy operation is not allowed."); } lib.bwa.bigWebDesk.LinqBll.Context.AssetMakes NewMake = new lib.bwa.bigWebDesk.LinqBll.Context.AssetMakes(); NewMake.TypeId = TypeID; NewMake.DepartmentId = DepartmentId; NewMake.Make = MakeName; dc.AssetMakes.InsertOnSubmit(NewMake); dc.SubmitChanges(); return(null); } }
public static int?GetMakeId(lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, int DepartmentID, string Name, int?AssetTypeId) { if (string.IsNullOrEmpty(Name)) { return(null); } IQueryable <int> IDs; IDs = from d in dc.AssetMakes where d.DepartmentId == DepartmentID && d.Make == Name select d.Id; foreach (int ID in IDs) { return(ID); } if (AssetTypeId == null) { return(null); } lib.bwa.bigWebDesk.LinqBll.Context.AssetMakes data = new lib.bwa.bigWebDesk.LinqBll.Context.AssetMakes(); data.DepartmentId = DepartmentID; data.Make = Name; data.TypeId = (int)AssetTypeId; dc.AssetMakes.InsertOnSubmit(data); dc.SubmitChanges(); return(data.Id); }
public static int? GetMakeId(lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, int DepartmentID, string Name, int? AssetTypeId) { if (string.IsNullOrEmpty(Name)) return null; IQueryable<int> IDs; IDs = from d in dc.AssetMakes where d.DepartmentId == DepartmentID && d.Make == Name select d.Id; foreach (int ID in IDs) return ID; if (AssetTypeId == null) return null; lib.bwa.bigWebDesk.LinqBll.Context.AssetMakes data = new lib.bwa.bigWebDesk.LinqBll.Context.AssetMakes(); data.DepartmentId = DepartmentID; data.Make = Name; data.TypeId = (int)AssetTypeId; dc.AssetMakes.InsertOnSubmit(data); dc.SubmitChanges(); return data.Id; }
public static string Copy(Guid OrgId, int DepartmentId, int MakeID, int TypeID) { using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection)) { var Makes = from t in dc.AssetMakes where t.Id == MakeID && t.DepartmentId == DepartmentId select t; var Make = Makes.FirstOrNull(); if (Make == null) return "Can not find specified asset make."; string MakeName = Make.Make; Makes = from t in dc.AssetMakes where t.DepartmentId == DepartmentId && t.TypeId == TypeID && t.Make == Make.Make select t; Make = Makes.FirstOrNull(); if (Make != null) return "'" + MakeName + "' asset make exists in destination asset category. Copy operation is not allowed."; lib.bwa.bigWebDesk.LinqBll.Context.AssetMakes NewMake = new lib.bwa.bigWebDesk.LinqBll.Context.AssetMakes(); NewMake.TypeId = TypeID; NewMake.DepartmentId = DepartmentId; NewMake.Make = MakeName; dc.AssetMakes.InsertOnSubmit(NewMake); dc.SubmitChanges(); return null; } }