示例#1
0
        public DTO.EditFormData GetData(int userId, int id, int clientID, int factoryID, string season, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.EditFormData data = new DTO.EditFormData();
            data.Data          = new DTO.FactoryProformaInvoice();
            data.DeliveryTerms = new List <Support.DTO.DeliveryTerm>();
            data.PaymentTerms  = new List <Support.DTO.PaymentTerm>();
            data.Data.FactoryProformaInvoiceDetails = new List <DTO.FactoryProformaInvoiceDetail>();

            //try to get data
            try
            {
                // check permission
                if (id <= 0 && fwFactory.CheckFactoryPermission(userId, factoryID) == 0)
                {
                    throw new Exception("Current user don't have access permission for the selected factory data");
                }
                if (id > 0 && fwFactory.CheckFactoryProformaInvoicePermission(userId, id) == 0)
                {
                    throw new Exception("Current user don't have access permission for the selected proforma invoice data");
                }

                using (FactoryProformaInvoice2MngEntities context = CreateContext())
                {
                    if (id <= 0)
                    {
                        data.Data.Season      = season;
                        data.Data.InvoiceDate = DateTime.Now.ToString("dd/MM/yyyy");
                        data.Data.ClientID    = clientID;
                        data.Data.FactoryID   = factoryID;
                        data.Data.ClientUD    = supportFactory.GetClient().FirstOrDefault(o => o.ClientID == clientID).ClientUD;
                        data.Data.FactoryUD   = supportFactory.GetFactory().FirstOrDefault(o => o.FactoryID == factoryID).FactoryUD;
                    }
                    else
                    {
                        data.Data = converter.DB2DTO_FactoryProformaInvoice(context.FactoryProformaInvoice2Mng_FactoryProformaInvoice_View.Include("FactoryProformaInvoice2Mng_FactoryProformaInvoiceDetail_View").FirstOrDefault(o => o.FactoryProformaInvoiceID == id));
                    }
                }
                data.DeliveryTerms = supportFactory.GetDeliveryTerm();
                data.PaymentTerms  = supportFactory.GetPaymentTerm();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
示例#2
0
        public DTO.InitDTO GetInitDataReport(int userId, out Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            Support.DAL.DataFactory spF  = new Support.DAL.DataFactory();
            DTO.InitDTO             data = new InitDTO();
            int?companyID = fw_factory.GetCompanyID(userId);

            try
            {
                using (var context = CreateContext())
                {
                    data.productionTeams = AutoMapper.Mapper.Map <List <SupportMng_ProductionTeam_View>, List <Support.DTO.ProductionTeam> >(context.SupportMng_ProductionTeam_View.ToList()).ToList();
                }
                data.clients = spF.GetClient().ToList();

                return(data);
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = Library.Helper.GetInnerException(ex).Message;
                return(data);
            }
        }
示例#3
0
        public DTO.EditFormData GetData(int userId, int id, int clientId, string season, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            var data = new DTO.EditFormData {
                Data = new DTO.ClientComplaint()
            };

            try
            {
                using (var context = CreateContext())
                {
                    if (id <= 0)
                    {
                        // create new
                        data.Data.YearSeason           = season;
                        data.Data.ClientID             = clientId;
                        data.Data.ReceivedDate         = DateTime.Now.ToShortDateString();
                        data.Data.ClientComplaintItems = new List <DTO.ClientComplaintItem>();
                        data.Data.ClientComplaintUsers = new List <DTO.ClientComplaintUser>();

                        var client = _supportFactory.GetClient().FirstOrDefault(o => o.ClientID == clientId);
                        if (client != null)
                        {
                            data.Data.ClientUD = client.ClientUD;
                            data.Data.ClientNM = client.ClientNM;

                            var saleMn = _supportFactory.GetSaler().FirstOrDefault(s => s.SaleID == client.SaleID);
                            if (saleMn != null)
                            {
                                data.Data.SaleNM = saleMn.SaleNM;
                            }
                        }
                    }
                    else
                    {
                        // access data from db
                        var item = context.ClientComplaint_ClientComplaint_View.FirstOrDefault(o => o.ClientComplaintID == id);
                        data.Data = _converter.DB2DTO_ClientComplaint(item);
                    }
                }

                data.Employees         = _supportFactory.GetEmployee().ToList();
                data.ComplaintStatuses = _supportFactory.GetConstantEntries(EntryGroupType.ComplaintStatus);
                data.ComplaintTypes    = _supportFactory.GetConstantEntries(EntryGroupType.ComplaintType);
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
示例#4
0
        public string GetExcelReportData(int clientId, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            ReportDataObject ds = new ReportDataObject();

            try
            {
                SqlDataAdapter adap = new SqlDataAdapter();
                adap.SelectCommand             = new SqlCommand("ClientPaymentOverviewRpt_function_GetReport", new SqlConnection(Library.Helper.GetSQLConnectionString()));
                adap.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
                adap.SelectCommand.Parameters.AddWithValue("@ClientID", clientId);
                adap.TableMappings.Add("Table", "ClientPaymentOverviewRpt_DownPayment_View");
                adap.TableMappings.Add("Table1", "ClientPaymentOverviewRpt_Invoice_View");
                adap.Fill(ds);

                // add report param
                ReportDataObject.ReportHeaderRow pRow = ds.ReportHeader.NewReportHeaderRow();
                pRow.Season   = string.Empty;
                pRow.ClientNM = supportFactory.GetClient().FirstOrDefault(o => o.ClientID == clientId).ClientNM;
                pRow.ExRate   = Convert.ToDecimal(supportFactory.GetSettingValue(Library.OMSHelper.Helper.GetCurrentSeason(), "ExRate-EUR-USD"), new System.Globalization.CultureInfo("en-US"));
                ds.ReportHeader.AddReportHeaderRow(pRow);

                // dev
                //Library.Helper.DevCreateReportXMLSource(ds, "ClientPaymentOverview");

                // generate xml file
                //return Library.Helper.CreateCOMReportFile(ds, "ClientPaymentOverview");
                return(Library.Helper.CreateReportFiles(ds, "ClientPaymentOverview"));
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
                return(string.Empty);
            }
        }
示例#5
0
        public DTO.InitFormData GetInit(out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.InitFormData result = new DTO.InitFormData();
            result.Clients = new List <Support.DTO.Client>();
            result.ClientPaymentMethods = new List <Support.DTO.ClientPaymentMethod>();
            try
            {
                result.Clients = supportFactory.GetClient();
                result.ClientPaymentMethods = supportFactory.GetClientPaymentMethod();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(result);
        }
示例#6
0
        public SearchFormData GetDataWithFilter(int userID, Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Notification notification)
        {
            // Define.
            SearchFormData searchFormData = new SearchFormData
            {
                SearchData = new List <SampleProductLocationSearchResultData>(),
                Seasons    = new List <Support.DTO.Season>(),
                Locations  = new List <SupportFactoryLocationData>(),
                Factories  = new List <Support.DTO.Factory>(),
                Clients    = new List <Support.DTO.Client>(),
                Statuses   = new List <Support.DTO.SampleProductStatus>()
            };

            notification = new Notification
            {
                Type = NotificationType.Success
            };

            totalRows = 0;

            // Main.
            try
            {
                string season = null;
                string sampleProductItemUD = null;
                string articleDescription  = null;
                string factoryUD           = null;
                string locationUD          = null;
                string clientUD            = null;
                int?   quantity            = null;
                int?   statusID            = null;

                if (filters.ContainsKey("Season") && filters["Season"] != null && !string.IsNullOrEmpty(filters["Season"].ToString().Replace("'", "''")))
                {
                    season = filters["Season"].ToString().Trim();
                }

                if (filters.ContainsKey("Code") && filters["Code"] != null && !string.IsNullOrEmpty(filters["Code"].ToString().Replace("'", "''")))
                {
                    sampleProductItemUD = filters["Code"].ToString().Trim();
                }

                if (filters.ContainsKey("ArticleDescription") && filters["ArticleDescription"] != null && !string.IsNullOrEmpty(filters["ArticleDescription"].ToString().Replace("'", "''")))
                {
                    articleDescription = filters["ArticleDescription"].ToString().Trim();
                }

                if (filters.ContainsKey("Factory") && filters["Factory"] != null && !string.IsNullOrEmpty(filters["Factory"].ToString().Replace("'", "''")))
                {
                    factoryUD = filters["Factory"].ToString().Trim();
                }

                if (filters.ContainsKey("Location") && filters["Location"] != null && !string.IsNullOrEmpty(filters["Location"].ToString().Replace("'", "''")))
                {
                    locationUD = filters["Location"].ToString().Trim();
                }

                if (filters.ContainsKey("Client") && filters["Client"] != null && !string.IsNullOrEmpty(filters["Client"].ToString().Replace("'", "''")))
                {
                    clientUD = filters["Client"].ToString().Trim();
                }

                if (filters.ContainsKey("Quantity") && filters["Quantity"] != null && !string.IsNullOrEmpty(filters["Quantity"].ToString().Replace("'", "''")))
                {
                    quantity = Convert.ToInt32(filters["Quantity"].ToString().Trim());
                }

                if (filters.ContainsKey("Status") && filters["Status"] != null && !string.IsNullOrEmpty(filters["Status"].ToString().Replace("'", "''")))
                {
                    statusID = Convert.ToInt32(filters["Status"].ToString().Trim());
                }

                using (var context = CreateContext())
                {
                    totalRows = context.SampleProductLocationMng_function_SampleProductLocationSearchResult(season, sampleProductItemUD, articleDescription, factoryUD, locationUD, clientUD, quantity, statusID, userID, orderBy, orderDirection).Count();

                    var results = context.SampleProductLocationMng_function_SampleProductLocationSearchResult(season, sampleProductItemUD, articleDescription, factoryUD, locationUD, clientUD, quantity, statusID, userID, orderBy, orderDirection);
                    searchFormData.SearchData = converter.DB2DTO_SampleLocationSearch(results.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());

                    var factoryResult = context.SampleProductLocationMng_function_SupportFactoryLocation(userID.ToString());
                    searchFormData.Locations = converter.DB2DTO_SampleFactory(factoryResult.ToList());
                }

                searchFormData.Seasons   = supportFactory.GetSeason().ToList();
                searchFormData.Clients   = supportFactory.GetClient().ToList();
                searchFormData.Factories = supportFactory.GetFactory(userID).ToList();
                searchFormData.Statuses  = supportFactory.GetSampleProductStatus().ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = NotificationType.Error;
                notification.Message = ex.Message;
                searchFormData       = null;
            }

            // Result.
            return(searchFormData);
        }
示例#7
0
 public override DTO.SearchFormData GetDataWithFilter(Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
 {
     DTO.SearchFormData searchFormData = new DTO.SearchFormData();
     notification = new Library.DTO.Notification()
     {
         Type = Library.DTO.NotificationType.Success
     };
     totalRows = 0;
     try
     {
         string clientNM    = null;
         string validFrom   = null;
         string validTo     = null;
         string description = null;
         string updatedDate = null;
         string updatorName = null;
         int?   clientID    = null;
         if (filters.ContainsKey("clientNM") && !string.IsNullOrEmpty(filters["clientNM"].ToString()))
         {
             clientNM = filters["clientNM"].ToString().Replace("'", "''");
         }
         if (filters.ContainsKey("validFrom") && !string.IsNullOrEmpty(filters["validFrom"].ToString()))
         {
             validFrom = filters["validFrom"].ToString().Replace("'", "''");
         }
         if (filters.ContainsKey("validTo") && !string.IsNullOrEmpty(filters["validTo"].ToString()))
         {
             validTo = filters["validTo"].ToString().Replace("'", "''");
         }
         if (filters.ContainsKey("description") && !string.IsNullOrEmpty(filters["description"].ToString()))
         {
             description = filters["description"].ToString().Replace("'", "''");
         }
         if (filters.ContainsKey("updatorName") && !string.IsNullOrEmpty(filters["updatorName"].ToString()))
         {
             updatorName = filters["updatorName"].ToString().Replace("'", "''");
         }
         if (filters.ContainsKey("updatedDate") && !string.IsNullOrEmpty(filters["updatedDate"].ToString()))
         {
             updatedDate = filters["updatedDate"].ToString().Replace("'", "''");
         }
         if (filters.ContainsKey("clientID") && filters["clientID"] != null)
         {
             clientID = Convert.ToInt32(filters["clientID"]);
         }
         using (ClientOfferMngEntities context = CreateContext())
         {
             totalRows = context.ClientOfferMng_function_SearchClientOffer(orderBy, orderDirection, clientID, clientNM, validFrom, validTo, description, updatedDate, updatorName).Count();
             var result = context.ClientOfferMng_function_SearchClientOffer(orderBy, orderDirection, clientID, clientNM, validFrom, validTo, description, updatedDate, updatorName);
             searchFormData.Data = converter.DB2DTO_ClientOfferSearch(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
         }
         searchFormData.Clients = supportFactory.GetClient();
         return(searchFormData);
     }
     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(searchFormData);
     }
 }