Ejemplo n.º 1
0
 private void button7_Click(object sender, EventArgs e)
 {
     try
     {
         var timesetting = _iTimeSettingService.GetAll().OrderByDescending(x => x.UpdateDate).FirstOrDefault();
         if (timesetting != null)
         {
             timesetting.time = dateTimePicker5.Value;
             timesetting.UpdateDate = DateTime.Now;
             _iTimeSettingService.Update(timesetting);
         }
         else
         {
             timesetting = new TimeSetting();
             timesetting.UpdateDate = DateTime.Now;
             timesetting.time = dateTimePicker5.Value;
             _iTimeSettingService.Create(timesetting);
         }
         _iTimeSettingService.Save();
         var successForm = new SuccessForm();
         successForm.ShowDialog();
     }
     catch (Exception ex)
     {
         var errorForm = new ErrorForm(ex.Message);
         errorForm.ShowDialog();
     }
 }
Ejemplo n.º 2
0
 private void drawEfficiency()
 {
     int index = 0;
     foreach (string j in _data)
     {
         var code = j.Split('-')[0].ToString();
         chart1.Series.Add(code);
         chart1.Series[index].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
         if (index > colorList.Count() - 1)
             chart1.Series[index].Color = colorList[0];
         else
             chart1.Series[index].Color = colorList[index];
         chart1.Series[index].BorderWidth = 2;
         chart1.Series[index].XValueType = ChartValueType.DateTime;
         List<Sale> saleResult = _iSaleService.GetQuantity(_minDate, _maxDate, code);
         var timesetting = _iTimeSettingService.GetAll().ToList().FirstOrDefault();
         if (timesetting == null)
             timesetting = new TimeSetting { time = new DateTime(2015, 8, 3, 6, 0, 0) };
         var time1 = timesetting.time;
         var freq = _iReportService.GetItemFreq(_minDate, _maxDate, time1, code);
         var item = _iProgramService.FindItem(code);
         foreach (var i in saleResult)
         {
             var amount = Convert.ToInt32(item.Price) * i.Quantity;
             var totalTime = 0.0;
             if (freq.Count() > 0)
             {
                 totalTime = freq[index].Freq * (Convert.ToDateTime(item.Duration).Minute + Convert.ToDateTime(item.Duration).Second / 60.0);
             }
             if (totalTime != 0.0)
             {
                 chart1.Series[index].Points.AddXY(i.Date, amount / totalTime);
             }
             else
             {
                 chart1.Series[index].Points.AddXY(i.Date, 0);
             }
         }
         index++;
     }
 }