Ejemplo n.º 1
0
        public static string Copy(Guid OrgId, int DepartmentId, int ModelID, int MakeID)
        {
            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 Models = from t in dc.AssetModels where t.Id == ModelID && t.DepartmentId == DepartmentId select t;
                var Model  = Models.FirstOrNull();
                if (Model == null)
                {
                    return("Can not find specified asset model.");
                }

                string ModelName  = Model.Model;
                string ModelLinks = Model.Links;

                Models = from t in dc.AssetModels where t.DepartmentId == DepartmentId && t.MakeId == MakeID && t.Model == ModelName select t;
                Model  = Models.FirstOrNull();
                if (Model != null)
                {
                    return("'" + ModelName + "' asset model already exists in destination asset make. Copy operation is not allowed.");
                }

                lib.bwa.bigWebDesk.LinqBll.Context.AssetModels NewModel = new lib.bwa.bigWebDesk.LinqBll.Context.AssetModels();
                NewModel.MakeId       = MakeID;
                NewModel.DepartmentId = DepartmentId;
                NewModel.Model        = ModelName;
                NewModel.Links        = ModelLinks;

                dc.AssetModels.InsertOnSubmit(NewModel);
                dc.SubmitChanges();
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static int?GetModelId(lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, int DepartmentID, string Name, int?AssetMakeId)
        {
            if (string.IsNullOrEmpty(Name))
            {
                return(null);
            }
            IQueryable <int> IDs;

            IDs = from d in dc.AssetModels where d.DepartmentId == DepartmentID && d.Model == Name select d.Id;
            foreach (int ID in IDs)
            {
                return(ID);
            }

            if (AssetMakeId == null)
            {
                return(null);
            }

            lib.bwa.bigWebDesk.LinqBll.Context.AssetModels data = new lib.bwa.bigWebDesk.LinqBll.Context.AssetModels();
            data.DepartmentId = DepartmentID;
            data.Model        = Name;
            data.MakeId       = (int)AssetMakeId;

            dc.AssetModels.InsertOnSubmit(data);
            dc.SubmitChanges();
            return(data.Id);
        }
Ejemplo n.º 3
0
        public static string Copy(Guid OrgId, int DepartmentId, int ModelID, int MakeID)
        {
            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 Models = from t in dc.AssetModels where t.Id == ModelID && t.DepartmentId == DepartmentId select t;
                var Model = Models.FirstOrNull();
                if (Model == null) return "Can not find specified asset model.";

                string ModelName = Model.Model;
                string ModelLinks = Model.Links;

                Models = from t in dc.AssetModels where t.DepartmentId == DepartmentId && t.MakeId == MakeID && t.Model == ModelName select t;
                Model = Models.FirstOrNull();
                if (Model != null) return "'" + ModelName + "' asset model already exists in destination asset make. Copy operation is not allowed.";

                lib.bwa.bigWebDesk.LinqBll.Context.AssetModels NewModel = new lib.bwa.bigWebDesk.LinqBll.Context.AssetModels();
                NewModel.MakeId = MakeID;
                NewModel.DepartmentId = DepartmentId;
                NewModel.Model = ModelName;
                NewModel.Links = ModelLinks;

                dc.AssetModels.InsertOnSubmit(NewModel);
                dc.SubmitChanges();
                return null;
            }
        }
Ejemplo n.º 4
0
        public static int? GetModelId(lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, int DepartmentID, string Name, int? AssetMakeId)
        {
            if (string.IsNullOrEmpty(Name)) return null;
            IQueryable<int> IDs;
            IDs = from d in dc.AssetModels where d.DepartmentId == DepartmentID && d.Model == Name select d.Id;
            foreach (int ID in IDs) return ID;

            if (AssetMakeId == null) return null;

            lib.bwa.bigWebDesk.LinqBll.Context.AssetModels data = new lib.bwa.bigWebDesk.LinqBll.Context.AssetModels();
            data.DepartmentId = DepartmentID;
            data.Model = Name;
            data.MakeId = (int)AssetMakeId;

            dc.AssetModels.InsertOnSubmit(data);
            dc.SubmitChanges();
            return data.Id;
        }