Exemple #1
0
        public override DTO.SearchFormDataDTO GetDataWithFilter(Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
        {
            DTO.SearchFormDataDTO data = new DTO.SearchFormDataDTO();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            totalRows = 0;
            Module.Support.DAL.DataFactory supportFactory = new Support.DAL.DataFactory();

            string factoryFinishedProductUD = string.Empty;
            string factoryFinishedProductNM = string.Empty;
            int?   factoryTeamID            = null;
            int?   factoryStepID            = null;

            if (filters.ContainsKey("factoryFinishedProductUD"))
            {
                factoryFinishedProductUD = filters["factoryFinishedProductUD"].ToString();
            }
            if (filters.ContainsKey("factoryFinishedProductNM"))
            {
                factoryFinishedProductNM = filters["factoryFinishedProductNM"].ToString();
            }
            if (filters.ContainsKey("factoryTeamID") && filters["factoryTeamID"] != null)
            {
                factoryTeamID = Convert.ToInt32(filters["factoryTeamID"].ToString());
            }
            if (filters.ContainsKey("factoryStepID") && filters["factoryStepID"] != null)
            {
                factoryStepID = Convert.ToInt32(filters["factoryStepID"].ToString());
            }

            try
            {
                using (FactoryFinishedProductEntities context = CreateContext())
                {
                    totalRows = context.FactoryFinishedProductMng_function_SearchFactoryFinishedProduct(orderBy, orderDirection, factoryFinishedProductUD, factoryFinishedProductNM, factoryTeamID, factoryStepID).Count();
                    var result = context.FactoryFinishedProductMng_function_SearchFactoryFinishedProduct(orderBy, orderDirection, factoryFinishedProductUD, factoryFinishedProductNM, factoryTeamID, factoryStepID);
                    data.Data = converter.DB2DTO_FactoryFinishedProductSearch(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
                }
                data.FactoryTeams = supportFactory.GetFactoryTeam();
                data.FactorySteps = supportFactory.GetFactoryStep();
                return(data);
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                notification.DetailMessage.Add(ex.Message);
                if (ex.GetBaseException() != null)
                {
                    notification.DetailMessage.Add(ex.GetBaseException().Message);
                }
                return(new DTO.SearchFormDataDTO());
            }
        }
 public override DTO.EditFormData GetData(int id, out Library.DTO.Notification notification)
 {
     DTO.EditFormData editFormData = new DTO.EditFormData();
     notification = new Library.DTO.Notification()
     {
         Type = Library.DTO.NotificationType.Success
     };
     Module.Support.DAL.DataFactory support_factory = new Support.DAL.DataFactory();
     try
     {
         using (FactoryFinishedProductReceiptEntities context = CreateContext())
         {
             if (id > 0)
             {
                 FactoryFinishedProductReceiptMng_FactoryFinishedProductReceipt_View dbItem;
                 dbItem            = context.FactoryFinishedProductReceiptMng_FactoryFinishedProductReceipt_View.FirstOrDefault(o => o.FactoryFinishedProductReceiptID == id);
                 editFormData.Data = converter.DB2DTO_FactoryFinishedProductReceipt(dbItem);
             }
             else
             {
                 editFormData.Data        = new DTO.FactoryFinishedProductReceipt();
                 editFormData.Data.Season = Library.Helper.GetCurrentSeason();
                 editFormData.Data.FactoryFinishedProductReceiptDetails = new List <DTO.FactoryFinishedProductReceiptDetail>();
             }
             editFormData.Seasons      = support_factory.GetSeason();
             editFormData.FactoryTeams = support_factory.GetFactoryTeam();
             //editFormData.FactoryAreas = support_factory.GetFactoryArea();
             //editFormData.FactoryGoodsProcedureDetails = support_factory.GetFactoryGoodsProcedureDetail();
             editFormData.FactorySteps = support_factory.GetFactoryStep();
             return(editFormData);
         }
     }
     catch (Exception ex)
     {
         notification.Type    = Library.DTO.NotificationType.Error;
         notification.Message = ex.Message;
         notification.DetailMessage.Add(ex.Message);
         if (ex.GetBaseException() != null)
         {
             notification.DetailMessage.Add(ex.GetBaseException().Message);
         }
         return(editFormData);
     }
 }
        public override DTO.EditFormData GetData(int id, out Library.DTO.Notification notification)
        {
            DTO.EditFormData editFormData = new DTO.EditFormData();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            Module.Support.DAL.DataFactory support_factory = new Support.DAL.DataFactory();
            try
            {
                using (FactoryStepNormEntities context = CreateContext())
                {
                    if (id > 0)
                    {
                        FactoryStepNormMng_FactoryStepNorm_View dbItem;
                        dbItem            = context.FactoryStepNormMng_FactoryStepNorm_View.FirstOrDefault(o => o.FactoryStepNormID == id);
                        editFormData.Data = converter.DB2DTO_FactoryStepNorm(dbItem);
                    }
                    else
                    {
                        editFormData.Data = new DTO.FactoryStepNorm();
                        editFormData.Data.FactoryStepNormDetails = new List <DTO.FactoryStepNormDetail>();
                    }

                    //get support list
                    editFormData.Units        = support_factory.GetUnit(2);
                    editFormData.FactorySteps = support_factory.GetFactoryStep();
                    return(editFormData);
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                notification.DetailMessage.Add(ex.Message);
                if (ex.GetBaseException() != null)
                {
                    notification.DetailMessage.Add(ex.GetBaseException().Message);
                }
                return(editFormData);
            }
        }
 public override DTO.EditFormDataDTO GetData(int id, out Library.DTO.Notification notification)
 {
     notification = new Library.DTO.Notification()
     {
         Type = Library.DTO.NotificationType.Success
     };
     Module.Support.DAL.DataFactory supportFactory = new Support.DAL.DataFactory();
     DTO.EditFormDataDTO            dtoItem        = new DTO.EditFormDataDTO();
     try
     {
         using (FactoryTeamEntities context = CreateContext())
         {
             if (id > 0)
             {
                 FactoryTeam dbItem;
                 dbItem       = context.FactoryTeam.FirstOrDefault(o => o.FactoryTeamID == id);
                 dtoItem.Data = converter.DB2DTO_FactoryTeam(dbItem);
             }
             else
             {
                 dtoItem.Data = new DTO.FactoryTeamDTO();
                 dtoItem.Data.FactoryMaterialGroupTeamDTOs = new List <DTO.FactoryMaterialGroupTeamDTO>();
                 dtoItem.Data.FactoryTeamStepDTOs          = new List <DTO.FactoryTeamStepDTO>();
             }
             dtoItem.FactorySteps          = supportFactory.GetFactoryStep();
             dtoItem.FactoryMaterialGroups = supportFactory.GetFactoryMaterialGroup();
             return(dtoItem);
         }
     }
     catch (Exception ex)
     {
         notification.Type    = Library.DTO.NotificationType.Error;
         notification.Message = ex.Message;
         notification.DetailMessage.Add(ex.Message);
         if (ex.GetBaseException() != null)
         {
             notification.DetailMessage.Add(ex.GetBaseException().Message);
         }
         return(null);
     }
 }
Exemple #5
0
        public override DTO.EditFormDataDTO GetData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.EditFormDataDTO            editFormData    = new DTO.EditFormDataDTO();
            Module.Support.DAL.DataFactory support_factory = new Support.DAL.DataFactory();
            // Try to get data.
            try
            {
                using (FactoryGoodsProcedureEntities context = CreateContext())
                {
                    if (id > 0)
                    {
                        FactoryGoodsProcedureMng_FactoryGoodsProcedure_View dbItem;
                        dbItem                    = context.FactoryGoodsProcedureMng_FactoryGoodsProcedure_View.FirstOrDefault(o => o.FactoryGoodsProcedureID == id);
                        editFormData.Data         = converter.DB2DTO_FactoryGoodsProcedure(dbItem);
                        editFormData.FactorySteps = null;
                    }
                    else
                    {
                        editFormData.Data = new DTO.FactoryGoodsProcedureDTO();
                        editFormData.Data.FactoryGoodsProcedureDetailDTOs = new List <DTO.FactoryGoodsProcedureDetailDTO>();
                    }
                    editFormData.FactorySteps = support_factory.GetFactoryStep();
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(editFormData);
        }