示例#1
0
        public int GetGridDataAllCustomersAllYears()
        {
            SalesLeadsList.Clear();
            try
            {
                if (_context != null)
                {
                    _context.Dispose();
                    _context = new MONITOREntities1();
                }

                if (_context != null)
                {
                    var q = from cl in _context.vw_ST_LightingStudy_Hitlist_2016
                            where cl.SOPYear == 2017 || cl.SOPYear == 2018 || cl.SOPYear == 2019
                            orderby cl.SOP, cl.Program
                    select cl;

                    foreach (var item in q.ToList())
                    {
                        _salesLeadDataModel = new SalesLeadDataModel
                        {
                            Customer      = item.Customer,
                            Program       = item.Program,
                            Application   = item.Application,
                            Sop           = item.SOP,
                            Eop           = item.EOP,
                            Volume        = string.Format("{0:n0}", item.PeakYearlyVolume),
                            Status        = item.Status,
                            AwardedVolume = (item.AwardedVolume.HasValue) ? string.Format("{0:n0}", item.AwardedVolume) : "",
                            ID            = item.ID
                        };
                        SalesLeadsList.Add(_salesLeadDataModel);
                    }

                    if (SalesLeadsList.Count < 1)
                    {
                        _messageBox.Message = "No sales leads were found.";
                        _messageBox.ShowDialog();
                        return(0);
                    }
                }
            }
            catch (Exception ex)
            {
                string error = (ex.InnerException != null) ? ex.InnerException.Message : ex.Message;
                _messageBox.Message = string.Format("Failed to return sales lead data.  Error: {0}", error);
                _messageBox.ShowDialog();
                return(0);
            }
            return(1);
        }
示例#2
0
        public int GetGridDataOneCustomerOneYear(string customer, string year)
        {
            //var res = new ObjectParameter("Result", typeof(Int32));
            //var td = new ObjectParameter("TranDT", typeof(DateTime));

            //BindingSource = null;
            //BindingSource = new BindingSource();

            int iYear;

            try
            {
                iYear = Convert.ToInt32(year);
            }
            catch (Exception ex)
            {
                _messageBox.Message = string.Format("Year must be numeric");
                _messageBox.ShowDialog();
                return(0);
            }

            SalesLeadsList.Clear();
            try
            {
                if (_context != null)
                {
                    _context.Dispose();
                    _context = new MONITOREntities1();
                }

                if (_context != null)
                {
                    //_context.ST_Csm_SalesForecast.Where(sf => sf.parent_customer == parentCustomer).Load();
                    //if (!_context.ST_Csm_SalesForecast.Any()) return;
                    //BindingSource.DataSource = _context.ST_Csm_SalesForecast.Local;

                    var q = from cl in _context.vw_ST_LightingStudy_Hitlist_2016
                            where cl.Customer == customer && cl.SOPYear == iYear
                            orderby cl.SOP, cl.Program
                    select cl;

                    foreach (var item in q.ToList())
                    {
                        _salesLeadDataModel = new SalesLeadDataModel
                        {
                            Customer      = item.Customer,
                            Program       = item.Program,
                            Application   = item.Application,
                            Sop           = item.SOP,
                            Eop           = item.EOP,
                            Volume        = string.Format("{0:n0}", item.PeakYearlyVolume),
                            Status        = item.Status,
                            SalesPerson   = item.SalesPerson,
                            AwardedVolume = (item.AwardedVolume.HasValue) ? string.Format("{0:n0}", item.AwardedVolume) : "",
                            ID            = item.ID
                        };
                        SalesLeadsList.Add(_salesLeadDataModel);
                    }

                    if (SalesLeadsList.Count < 1)
                    {
                        _messageBox.Message = string.Format("No sales leads were found for {0}.", customer);
                        _messageBox.ShowDialog();
                        return(0);
                    }
                }
            }
            catch (Exception ex)
            {
                string error = (ex.InnerException != null) ? ex.InnerException.Message : ex.Message;
                _messageBox.Message = string.Format("Failed to return sales lead data.  Error: {0}", error);
                _messageBox.ShowDialog();
                return(0);
            }
            return(1);
        }