Beispiel #1
0
 public static ResponseModel AddBOMFile(BOMFileModel m, ref int _newID)
 {
     ACTION = "AddBOMFile(BOMFileModel)";
     try
     {
         _newID = 0;
         ResponseModel res = BOMFileDAL.AddBOMFile(m, ref _newID);
         return(new ResponseModel()
         {
             Action = ACTION,
             Source = SOURCE,
             Message = res.Message,
             Status = res.Status
         });
     }
     catch (Exception ex)
     {
         return(new ResponseModel()
         {
             Action = ACTION,
             Source = SOURCE,
             Message = ex.Message,
             Status = false
         });
     }
 }
Beispiel #2
0
        internal static USR_TMMA_BOM_FILE Mapping(BOMFileModel o)
        {
            try
            {
                if (o != null)
                {
                    return(new USR_TMMA_BOM_FILE()
                    {
                        BOMFileID = o.BOMFileID,
                        RecObjectName = o.RecObjectName,
                        UserSAP = o.UserSAP,
                        BOMFilePath = o.BOMFilePath,
                        BOMFileVersion = o.BOMFileVersion,
                        BOMFileStatus = o.BOMFileStatus,
                        ProductsTypeID = o.ProductsTypeID,
                        ValidDate = o.ValidDate,
                        IsActive = o.IsActive ? 1 : 0,
                        CreatedBy = o.CreatedBy,
                        CreatedDate = o.CreatedDate,
                        UpdatedBy = o.UpdatedBy,
                        UpdatedDate = o.UpdatedDate
                    });
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        public static BOMFileModel GetBOMFile(int bomFileID)
        {
            ACTION = "GetBOMFile(bomFileID)";

            try
            {
                using (UTMMABCDBEntities context = new UTMMABCDBEntities())
                {
                    USR_TMMA_BOM_FILE obj = context.USR_TMMA_BOM_FILE.Where(o => o.BOMFileID == bomFileID).FirstOrDefault();
                    BOMFileModel      m   = Mapping(obj);
                    return(m);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
        public static BOMFileModel GetBOMFileLastVersion(int ProductsTypeID)
        {
            ACTION = "GetBOMFileLastVersion()";
            try
            {
                using (UTMMABCDBEntities context = new UTMMABCDBEntities())
                {
                    var          list = context.USR_TMMA_BOM_FILE.Where(a => a.ProductsTypeID == ProductsTypeID).ToList();
                    var          o    = list.Last();
                    BOMFileModel m    = Mapping(o);

                    return(m);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void SaveBOMFileVersion(string path, string recObjectName, string userSAP, DateTime validDate, ref int version)
        {
            try
            {
                var enUser         = Environment.UserName;
                int ProductsTypeID = 2; // CCS
                var last           = core.GetBOMFileLastVersion(ProductsTypeID);
                version = (int)last.BOMFileVersion + 1;

                // Add BOMFile to Database
                BOMFileModel bomFile = new BOMFileModel();
                bomFile.ProductsTypeID = ProductsTypeID;
                bomFile.RecObjectName  = recObjectName;
                bomFile.UserSAP        = userSAP;
                bomFile.BOMFilePath    = path;
                bomFile.BOMFileStatus  = 1; // create new
                bomFile.BOMFileVersion = (decimal)(version);
                bomFile.ValidDate      = validDate;
                bomFile.IsActive       = true;
                bomFile.CreatedBy      = !string.IsNullOrEmpty(enUser) ? enUser : Session["Username"].ToString();
                bomFile.CreatedDate    = DateTime.Now;

                int           _newID = 0;
                ResponseModel res    = core.AddBOMFile(bomFile, ref _newID);

                if (!res.Status)
                {
                    throw new Exception(res.Message);
                }
                else
                {
                    log.Info("========== Save to Database Success. =========");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #6
0
        public static ResponseModel AddBOMFile(BOMFileModel m, ref int _newID)
        {
            string action = "AddBOMFile(BOMFileModel, out _newID)";

            _newID = 0;
            try
            {
                if (m != null)
                {
                    using (UTMMABCDBEntities context = new UTMMABCDBEntities())
                    {
                        USR_TMMA_BOM_FILE _obj = Mapping(m);

                        context.USR_TMMA_BOM_FILE.Add(_obj);

                        if (context.SaveChanges() > 0)
                        {
                            _newID = _obj.BOMFileID;

                            return(new ResponseModel()
                            {
                                Source = SOURCE,
                                Action = action,
                                Status = true,
                                Message = "Success"
                            });
                        }

                        return(new ResponseModel()
                        {
                            Source = SOURCE,
                            Action = action,
                            Status = false,
                            Message = "Fail"
                        });
                    }
                }

                return(new ResponseModel()
                {
                    Source = SOURCE,
                    Action = action,
                    Status = false,
                    Message = "Null"
                });
            }
            catch (DbEntityValidationException ex)
            {
                return(new ResponseModel()
                {
                    Source = SOURCE,
                    Action = action,
                    Status = false,
                    Message = ex.Message,
                    StackTrace = ex.StackTrace
                });
            }
            catch (Exception ex)
            {
                return(new ResponseModel()
                {
                    Source = SOURCE,
                    Action = action,
                    Status = false,
                    Message = ex.Message,
                    StackTrace = ex.StackTrace
                });
            }
        }
Beispiel #7
0
 public ResponseModel AddBOMFile(BOMFileModel m, ref int _newID)
 {
     return(BOMFileBLL.AddBOMFile(m, ref _newID));
 }