예제 #1
0
        /// <summary>
        /// Returns the week's number from the given date
        /// </summary>
        /// <param name="value">La date</param>
        /// <returns>Le n° de la semaine</returns>
        public static Int32 GetWeekOfYear(this DateTime value)
        {
            System.Globalization.DateTimeFormatInfo dfi      = System.Globalization.DateTimeFormatInfo.CurrentInfo;
            System.Globalization.Calendar           calendar = dfi.Calendar;

            return(calendar.GetWeekOfYear(value, dfi.CalendarWeekRule, dfi.FirstDayOfWeek));
        }
예제 #2
0
        private int GetWeekNumber(DateTime date)
        {
            System.Globalization.Calendar           calendar       = System.Threading.Thread.CurrentThread.CurrentCulture.Calendar;
            System.Globalization.DateTimeFormatInfo dateTimeFormat = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat;

            return(calendar.GetWeekOfYear(date, dateTimeFormat.CalendarWeekRule, dateTimeFormat.FirstDayOfWeek));
        }
        public static int GetWeek(DateTime date)
        {
            System.Globalization.CultureInfo cult_info = System.Globalization.CultureInfo.CreateSpecificCulture("no");
            System.Globalization.Calendar    cal       = cult_info.Calendar;
            int weekCount = cal.GetWeekOfYear(date, cult_info.DateTimeFormat.CalendarWeekRule, cult_info.DateTimeFormat.FirstDayOfWeek);

            return(weekCount);
        }
예제 #4
0
파일: Core.cs 프로젝트: githuis/P2Manage
        // This method returns the number of weeks in a given year
        public int GetWeeksInYear(int year, int month = 12, int day = 31)
        {
            System.Globalization.DateTimeFormatInfo dfi = System.Globalization.DateTimeFormatInfo.CurrentInfo;
            DateTime dt = new DateTime(year, month, day);

            System.Globalization.Calendar cal = dfi.Calendar;
            return(cal.GetWeekOfYear(dt, dfi.CalendarWeekRule, dfi.FirstDayOfWeek));
        }
예제 #5
0
        public static int GetCurrentWeek()
        {
            System.Globalization.DateTimeFormatInfo dfi      = (new System.Globalization.CultureInfo("nl-NL")).DateTimeFormat;
            System.Globalization.Calendar           calendar = dfi.Calendar;
            int weekNo = calendar.GetWeekOfYear(DateTime.Now, System.Globalization.CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);

            return(weekNo);
        }
예제 #6
0
        public static int GetPSCCalendarWeek(DateTime date)
        {
            DayOfWeek FirstDayOfWeek = DayOfWeek.Monday;

            System.Globalization.CultureInfo thisCulture = System.Globalization.CultureInfo.CreateSpecificCulture("zh-tw");
            System.Globalization.Calendar    calendar    = thisCulture.Calendar;;
            return(calendar.GetWeekOfYear(date, System.Globalization.CalendarWeekRule.FirstFullWeek, FirstDayOfWeek));
        }
예제 #7
0
        public override void GenerateFileName()
        {
            System.Globalization.CultureInfo cult_info = System.Globalization.CultureInfo.CreateSpecificCulture("no");
            System.Globalization.Calendar    cal       = cult_info.Calendar;
            int weekCount  = cal.GetWeekOfYear(DateTime.Now, cult_info.DateTimeFormat.CalendarWeekRule, cult_info.DateTimeFormat.FirstDayOfWeek);
            int monthCount = cal.GetMonth(DateTime.Now);

            //filename = "log." + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + ".txt";
            filename = "log." + weekCount.ToString() + DateTime.Now.Year.ToString() + ".txt";
        }
예제 #8
0
        public int GetWeeksOfYear(DateTime date)
        {
            System.Globalization.CultureInfo cult_info = System.Globalization.CultureInfo.CreateSpecificCulture("ko");
            System.Globalization.Calendar    cal       = cult_info.Calendar;
            int weekNo = cal.GetWeekOfYear(date, cult_info.DateTimeFormat.CalendarWeekRule, cult_info.DateTimeFormat.FirstDayOfWeek);

            return(weekNo);
            //int week1day = cal.GetWeekOfYear(date.AddDays(-(date.Day + 1)), cult_info.DateTimeFormat.CalendarWeekRule, cult_info.DateTimeFormat.FirstDayOfWeek);
            //Debug.Log("week1day : " + week1day);
            //return weekNo - week1day + 1;
        }
예제 #9
0
        public static int GetCalWeek()
        {
            int weekNo;

            System.Globalization.DateTimeFormatInfo dfi = System.Globalization.DateTimeFormatInfo.CurrentInfo;
            System.Globalization.Calendar           cal = dfi.Calendar;

            weekNo = cal.GetWeekOfYear(DateTime.Today, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);

            return(weekNo);
        }
예제 #10
0
        /// <summary>
        /// lay so tuan cua nam
        /// </summary>
        /// <param name="dateStart">DateTime</param>
        /// <returns></returns>
        public static int NumberWeekOfYear(DateTime dateStart)
        {
            try
            {
                System.Globalization.DateTimeFormatInfo dfi = System.Globalization.DateTimeFormatInfo.CurrentInfo;
                DateTime date1 = dateStart;
                System.Globalization.Calendar cal = dfi.Calendar;

                return(cal.GetWeekOfYear(date1, dfi.CalendarWeekRule, dfi.FirstDayOfWeek));
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
            return(0);
        }
예제 #11
0
        private int WeekOfYear()
        {
            // Gets the Calendar instance associated with a CultureInfo.
            System.Globalization.CultureInfo myCI  = new System.Globalization.CultureInfo("en-US");
            System.Globalization.Calendar    myCal = myCI.Calendar;

            // Gets the DTFI properties required by GetWeekOfYear.
            System.Globalization.CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule;
            DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;

            // Displays the number of the current week relative to the beginning of the year.
            //Console.WriteLine("The CalendarWeekRule used for the en-US culture is {0}.", myCWR);
            //Console.WriteLine("The FirstDayOfWeek used for the en-US culture is {0}.", myFirstDOW);
            //Console.WriteLine("Therefore, the current week is Week {0} of the current year.", myCal.GetWeekOfYear(DateTime.Now, myCWR, myFirstDOW));

            // Displays the total number of weeks in the current year.
            //System.DateTime LastDay = new System.DateTime(DateTime.Now.Year, 12, 31);
            //Console.WriteLine("There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year);

            return(myCal.GetWeekOfYear(DateTime.Now, myCWR, myFirstDOW));
        }
예제 #12
0
        public static int GetPSCCalendarYear(DateTime date)
        {
            DayOfWeek FirstDayOfWeek = DayOfWeek.Monday;

            System.Globalization.CultureInfo thisCulture = System.Globalization.CultureInfo.CreateSpecificCulture("zh-tw");
            System.Globalization.Calendar    calendar    = thisCulture.Calendar;;
            int week = calendar.GetWeekOfYear(date, System.Globalization.CalendarWeekRule.FirstFullWeek, FirstDayOfWeek);

            /*
             * 決定年份
             * 因為1月分week會是1~5,如果是52或53表示是被列為去年度的最後一周。
             *
             */
            if (date.Month == 1 && week > 10)   // 跨年
            {
                return(date.Year - 1);
            }
            else
            {
                return(date.Year);
            }
        }
예제 #13
0
 private int getWeekOfYear(DateTime date)
 {
     System.Globalization.DateTimeFormatInfo dfi = System.Globalization.DateTimeFormatInfo.CurrentInfo;
     System.Globalization.Calendar           cal = dfi.Calendar;
     return(cal.GetWeekOfYear(date, dfi.CalendarWeekRule, dfi.FirstDayOfWeek));
 }
예제 #14
0
        public ViewResult Management(DateTime?begin, DateTime?end, int prevnext = 0, int step = 5, string cat = "all", string rep = "", string title = "", int weektab = 0)
        {
            var now           = DateTime.Now;
            var articlesQuery = _articleRepository.GetMany(art => art.ArticleStatus > 0, art => art.PublishedTime);

            if (begin == null || end == null)
            {
                end   = Utilities.GetLastDateOfWeek(now, DayOfWeek.Sunday);
                begin = end.Value.AddDays(-7 * step).AddDays(1);
            }
            else
            {
                if (prevnext == 0)
                {
                    end   = Utilities.GetLastDateOfWeek(now, DayOfWeek.Sunday);
                    begin = end.Value.AddDays(-7 * step);
                }
                else if (prevnext == -1)
                {
                    end   = Utilities.GetFirstDateOfWeek(begin.Value, DayOfWeek.Monday).AddDays(-1);
                    begin = end.Value.AddDays(-7 * step).AddDays(1);
                }
                else if (prevnext == 1)
                {
                    begin = Utilities.GetLastDateOfWeek(end.Value, DayOfWeek.Sunday).AddDays(1);
                    end   = begin.Value.AddDays(7 * step);
                }
            }
            articlesQuery = articlesQuery.Where(v => v.PublishedTime.HasValue && v.PublishedTime.Value.Date >= begin && v.PublishedTime.Value.Date <= end);

            int catId;

            if (cat != "all" && int.TryParse(cat, out catId))
            {
                articlesQuery = articlesQuery.Where(v => v.Categories.Any(c => c.Id == catId));
            }

            if (rep != "")
            {
                articlesQuery = articlesQuery.Where(v => v.Reporters.Any(r => r.Name.Contains(rep)));
            }

            if (title != "")
            {
                articlesQuery = articlesQuery.Where(v => v.Title.Contains(title));
            }

            var startDate = begin.Value;
            var endDate   = end.Value;
            var list      = new List <ArticleCustomDateView>();

            for (int i = 0; i < 5; i++)
            {
                endDate = startDate.AddDays(6);
                var view = new ArticleCustomDateView
                {
                    Week      = cal.GetWeekOfYear(startDate, System.Globalization.CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday),
                    StartDate = startDate,
                    EndDate   = endDate,
                    Articles  = articlesQuery.Where(art => art.PublishedTime.HasValue && art.PublishedTime.Value.Date >= startDate && art.PublishedTime.Value.Date <= endDate)
                                .GroupJoin(_articleSeriesRepository.All, art => art.ArticleSeriesId, asr => asr.Id, (art, asr) => new { Art = art, Srs = asr })
                                .SelectMany(xy => xy.Srs.DefaultIfEmpty(), (x, y) => new { Art = x.Art, Srs = y })
                                .Select(a => new ArticleCustomView()
                    {
                        Id            = a.Art.Id,
                        ArticleName   = a.Art.Title,
                        SeriesName    = a.Srs != null && a.Srs.Articles.Count > 0 ? a.Srs.Name : "",
                        SeriesId      = a.Srs != null ? a.Srs.Id : 0,
                        IsPublished   = a.Art.IsPublished,
                        Order         = a.Art.Order,
                        PublishedTime = a.Art.PublishedTime,
                        Thumbnail     = a.Art.Thumbnail,
                        CatThumbnail  = a.Art.Categories.Count > 0? a.Art.Categories.ElementAt(0).ProfilePhoto:"",
                        CatName       = String.Join(", ", a.Art.Categories.OrderBy(r => r.Order).Select(r => r.Name)),
                        Reporters     = a.Art.Reporters.ToList(),
                        UniqueTitle   = a.Art.UniqueTitle,
                        ArticleStatus = a.Art.ArticleStatus,
                    }).ToList()
                };

                foreach (var art in view.Articles)
                {
                    var hlAll = _articleHighlightAllRepository.Find(art.Id);
                    var hlCat = _articleHighlightCatRepository.Find(art.Id);

                    art.IsHighlightAll = hlAll == null ? false : true;
                    art.IsHighlightCat = hlCat == null ? false : true;
                    var firstWeekReport = _articleRepository.GetFirstWeekReport(art.Id);
                    var allTimeReport   = _articleRepository.GetAllTimeReport(art.Id);
                    art.AllTimeCount   = allTimeReport.PageView;
                    art.FirstWeekCount = firstWeekReport.PageView;
                }

                list.Add(view);
                startDate = endDate.AddDays(1);
            }

            var filterView = new ArticleFilterView
            {
                Category       = cat,
                Reporter       = rep,
                Title          = title,
                Begin          = begin,
                End            = end,
                CustomArticles = list
            };

            ViewBag.weektab    = weektab;
            ViewBag.ArticleCat = _articleCategoryRepository.All.ToList();
            return(View(filterView));
        }
예제 #15
0
        private void Print_PrintPage(object sender, PrintPageEventArgs e)
        {
            //campos necesarios armado de etiqueta
            string     especie;
            string     variedad  = "";
            string     calibre   = "";
            string     embalaje  = "";
            string     productor = ProductorBox.Text;
            string     comuna    = "";
            ConexionDB conee     = new ConexionDB();
            string     provincia = conee.ObtenerProvincia(productor);

            conee.Cerrar();
            string region = "";
            //string ggn = "00000000000";
            string lote_huerto = loteBox.Text;
            string proceso_n   = nproceso_box.Text;
            int    turno       = 1;

            //ConexionDB cone2 = new ConexionDB();
            //string fda = cone2.ObtenerFDA(productor);
            //cone2.Cerrar();
            //string tipo_frio = "AR";
            especie = "APPLES";
            //if (saposalida.Equals("C1"))
            //{
            embalaje = EmbalajeBox.Text;
            turno    = 1;
            variedad = VariedadBox.Text;
            calibre  = CalibreBox.Text;
            //}

            //FUENTES A USAR
            Font prFont   = new Font("Arial", 5, FontStyle.Bold);
            Font prFont2  = new Font("Arial", 4, FontStyle.Bold);
            Font desFont  = new Font("Arial", 8, FontStyle.Bold);
            Font desFont2 = new Font("Arial", 6, FontStyle.Bold);

            ////genero numero codigo
            //numcode = "20201" + (ultimocodigo + 1).ToString();
            //StreamWriter escrito = File.CreateText("ultimaetiq.txt");
            //escrito.Write((ultimocodigo + 1).ToString());
            //escrito.Flush();
            //////Cerramos
            //escrito.Close();
            //ultimocodigo = ultimocodigo + 1;
            //Random Generator = new Random();
            //int numerorand, minimo, maximo;
            //int anioean = DateTime.Now.Year;

            //numcode = anioean + "00000000";
            ////GENERO DIGITO VERIFICADOR ean13
            //int v1;
            //int v2;
            //int verificador;

            //v1 = Convert.ToInt32(Convert.ToString(numcode).Substring(1, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(3, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(5, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(7, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(9, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(11, 1));
            //v1 = v1 * 3;
            //v2 = Convert.ToInt32(Convert.ToString(numcode).Substring(0, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(2, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(4, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(6, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(8, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(10, 1));

            //double redondea;
            //double aux;
            //redondea = (v1 + v2) / 10;
            //aux = redondea;
            //redondea = Math.Round(redondea, 0);
            //if (redondea > aux)
            //{
            //    redondea -= 1;
            //}
            //redondea = redondea + 1;
            //redondea = redondea * 10;
            //verificador = Convert.ToInt32(redondea) - (v1 + v2);
            //if (verificador.Equals(10))
            //{
            //    verificador = 0;
            //}

            //numcode = numcode + Convert.ToString(verificador);
            //ConexionDB versiexite = new ConexionDB();
            //while (versiexite.Existe_codigo(numcode))
            //{
            //    minimo = 10000000;
            //    maximo = 99999999;
            //    numerorand = Generator.Next(minimo, maximo + 1);
            //    numcode = anioean + Convert.ToString(numerorand);
            //    //GENERO DIGITO VERIFICADOR ean13

            //    v1 = Convert.ToInt32(Convert.ToString(numcode).Substring(1, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(3, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(5, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(7, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(9, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(11, 1));
            //    v1 = v1 * 3;
            //    v2 = Convert.ToInt32(Convert.ToString(numcode).Substring(0, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(2, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(4, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(6, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(8, 1)) + Convert.ToInt32(Convert.ToString(numcode).Substring(10, 1));

            //    redondea = (v1 + v2) / 10;
            //    aux = redondea;
            //    redondea = Math.Round(redondea, 0);
            //    if (redondea > aux)
            //    {
            //        redondea -= 1;
            //    }
            //    redondea = redondea + 1;
            //    redondea = redondea * 10;
            //    verificador = Convert.ToInt32(redondea) - (v1 + v2);
            //    if (verificador.Equals(10))
            //    {
            //        verificador = 0;
            //    }

            //    numcode = numcode + Convert.ToString(verificador);
            //}
            //versiexite.Cerrar();
            //Barcode128 bcode = new Barcode128
            //{
            //    BarHeight = 60,
            //    Code = numcode,
            //    GenerateChecksum = true,
            //    CodeType = Barcode.CODE128
            //};
            //Barcode128 bcode2 = new Barcode128
            //{
            //    BarHeight = 35,
            //    Code = numcode,
            //    GenerateChecksum = true,
            //    CodeType = Barcode.CODE128
            //};
            try
            {
                //Image img;
                //img = bcode2.CreateDrawingImage(Color.Black, Color.White);
                //img.RotateFlip(RotateFlipType.Rotate90FlipNone);
                //Image img2;
                //img2 = bcode.CreateDrawingImage(Color.Black, Color.White);
                int yPos = 6;

                Image logo;
                logo = Image.FromFile("etiq_santacatalina.jpg");
                //e.Graphics.DrawImage(logo, 265, yPos + 135, 106, 44);
                e.Graphics.DrawImage(logo, 0, yPos + 120, 106, 44);
                variedad = "red sensation";
                e.Graphics.DrawString(especie.ToUpper() + "-" + variedad.ToUpper(), new Font("Arial", 10, FontStyle.Bold), Brushes.Black, 40, yPos + 0);


                //e.Graphics.DrawString("AR", desFont2, Brushes.Black, 196, yPos + 0);
                Font prFont3 = new Font("Arial", 8, FontStyle.Bold);
                e.Graphics.DrawString("CSG:", desFont, Brushes.Black, 20, yPos + 24);
                e.Graphics.DrawString("GROWER / PRODUCTOR", new Font("Arial", 3, FontStyle.Bold), Brushes.Black, 11, yPos + 38);
                e.Graphics.DrawString("TOWNSHIP:", prFont3, Brushes.Black, 80, yPos + 26);
                e.Graphics.DrawString("PROVINCE:", prFont3, Brushes.Black, 80, yPos + 40);
                //e.Graphics.DrawString("GGN:", prFont, Brushes.Black, 0, yPos + 60);
                //ConexionDB cone = new ConexionDB();
                ConexionDB obtcsg = new ConexionDB();
                e.Graphics.DrawString(obtcsg.ObtenerCSG(productor), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 0, yPos + 42);
                obtcsg.Cerrar();
                //cone.Cerrar();
                //e.Graphics.DrawString(productor.ToUpper(), prFont, Brushes.Black, 70, yPos + 40);
                ConexionDB cone3 = new ConexionDB();
                comuna = cone3.ObtenerComuna(productor);
                e.Graphics.DrawString(comuna.ToUpper(), prFont3, Brushes.Black, 145, yPos + 26);
                cone3.Cerrar();
                ConexionDB conex3 = new ConexionDB();
                provincia = conex3.ObtenerProvincia(productor);
                e.Graphics.DrawString(provincia.ToUpper(), prFont3, Brushes.Black, 145, yPos + 40);
                conex3.Cerrar();
                //e.Graphics.DrawString("110987", desFont, Brushes.Black, 70, yPos + 26);                            //provisorio
                //e.Graphics.DrawString("SOCIEDAD PACKING SERVICE INGENIERIA LTDA.", prFont, Brushes.Black, 70, yPos + 40);   //provisorio
                //e.Graphics.DrawString("TENO - CURICO", prFont, Brushes.Black, 70, yPos + 50);                      //provisorio
                //e.Graphics.DrawString(ggn, prFont, Brushes.Black, 70, yPos + 60);
                ConexionDB cone5 = new ConexionDB();
                e.Graphics.DrawString("REGION: ", prFont3, Brushes.Black, 80, yPos + 54);
                region = cone5.ObtenerRegion(productor);
                e.Graphics.DrawString(region, prFont3, Brushes.Black, 145, yPos + 54);
                cone5.Cerrar();


                e.Graphics.DrawString("NET WEIGHT W.P.", prFont, Brushes.Black, 300, yPos + 5);
                string kilos = "5,0";
                if (embalaje.Contains("25K"))
                {
                    kilos = "2,5";
                }
                if (embalaje.Contains("9K"))
                {
                    kilos = "9";
                }
                if (embalaje.Contains("10K"))
                {
                    kilos = "10";
                }
                if (embalaje.Contains("18K"))
                {
                    kilos = "18";
                }
                if (embalaje.Contains("19K"))
                {
                    kilos = "19";
                }
                e.Graphics.DrawString(embalaje.TrimEnd().TrimStart() + " - " + kilos + " Kg.", prFont, Brushes.Black, 300, yPos + 12);
                int diasemana;
                System.Globalization.CultureInfo norwCulture = System.Globalization.CultureInfo.CreateSpecificCulture("es");
                System.Globalization.Calendar    cal         = norwCulture.Calendar;
                diasemana = cal.GetWeekOfYear(DateTime.Now, norwCulture.DateTimeFormat.CalendarWeekRule, norwCulture.DateTimeFormat.FirstDayOfWeek);
                e.Graphics.DrawString("SEM: ", prFont, Brushes.Black, 300, yPos + 23);
                e.Graphics.DrawString(diasemana.ToString(), prFont, Brushes.Black, 333, yPos + 23);
                //e.Graphics.DrawString("TIME: ", prFont, Brushes.Black, 300, yPos + 30);

                //e.Graphics.DrawString(DateTime.Now.ToString("HH:mm:ss"), prFont, Brushes.Black, 333, yPos + 30);
                e.Graphics.DrawString("N° PROCESO:", new Font("Arial", 7, FontStyle.Bold), Brushes.Black, 298, yPos + 40);
                if (proceso_n.Length.Equals(1))
                {
                    e.Graphics.DrawString(proceso_n, new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 328, yPos + 53);
                }
                if (proceso_n.Length.Equals(2))
                {
                    e.Graphics.DrawString(proceso_n, new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 323, yPos + 53);
                }
                if (proceso_n.Length.Equals(3))
                {
                    e.Graphics.DrawString(proceso_n, new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 318, yPos + 53);
                }
                if (proceso_n.Length.Equals(4))
                {
                    e.Graphics.DrawString(proceso_n, new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 315, yPos + 53);
                }


                //=================
                //if (calibre.Contains("D")) { e.Graphics.DrawString("DARK", new Font("Arial Black", 14, FontStyle.Bold), Brushes.Black, 200, yPos + 56); }
                //else
                //{
                //    //if (calibre.Contains("TC")) { e.Graphics.DrawString(" ", new Font("Arial Black", 12, FontStyle.Bold), Brushes.Black, 200, yPos + 56); }
                //    e.Graphics.DrawString("LIGHT", new Font("Arial Black", 13, FontStyle.Bold), Brushes.Black, 200, yPos + 56);
                //}

                e.Graphics.DrawString("DATE: ", new Font("Arial", 8, FontStyle.Bold), Brushes.Black, 160, yPos + 130);
                //e.Graphics.DrawString("LOTE: ", prFont, Brushes.Black, 222, yPos + 57);
                //e.Graphics.DrawString("PROC N°: ", prFont, Brushes.Black, 222, yPos + 57);
                e.Graphics.DrawString(FechaBox.Value.ToString("dd-MM-yyyy"), new Font("Arial", 12, FontStyle.Bold), Brushes.Black, 135, yPos + 142);
                //e.Graphics.DrawString(vaciado_lote, new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 255, yPos + 51);
                //e.Graphics.DrawString(proceso_n, prFont, Brushes.Black, 255, yPos + 57);


                Font desFont3 = new Font("Verdana", 22, FontStyle.Bold);
                Font desFont4 = new Font("Verdana", 14, FontStyle.Bold);
                //int exis = 150;
                //OBTENGO SIGLA CALIBRE
                //Cargar_siglaymm(calidad);
                //////////Sigla_clasificacion = "LL";
                //////////Calibre_mm = "< 23,9 mm";
                //if (Sigla_clasificacion.Length.Equals(2))
                //{
                //    e.Graphics.DrawString(Sigla_clasificacion, desFont3, Brushes.Black, exis + 2, yPos + 17);
                //}
                //else if (Sigla_clasificacion.Length.Equals(3))
                //{
                //    e.Graphics.DrawString(Sigla_clasificacion, desFont4, Brushes.Black, exis + 6, yPos + 17);
                //}
                //else if (Sigla_clasificacion.Length.Equals(4))
                //{
                //    e.Graphics.DrawString(Sigla_clasificacion, desFont3, Brushes.Black, exis - 4, yPos + 17);
                //}
                //else if (Sigla_clasificacion.Length.Equals(1))
                //{
                //    e.Graphics.DrawString(Sigla_clasificacion, desFont3, Brushes.Black, exis + 12, yPos + 17);
                //}
                //if (calibre.Replace("D", "").Length.Equals(4))
                //{
                //    e.Graphics.DrawString(calibre.Replace("D", ""), new Font("Arial Black", 24, FontStyle.Bold), Brushes.Black, exis + 24, yPos + 5);
                //}
                //if (calibre.Replace("D", "").Length.Equals(2))
                //{
                //    e.Graphics.DrawString(calibre.Replace("D", ""), new Font("Arial Black", 35, FontStyle.Bold), Brushes.Black, exis + 43, yPos - 3);
                //}
                //else if (calibre.Replace("D", "").Length.Equals(3))
                //{
                //    e.Graphics.DrawString(calibre.Replace("D", ""), desFont4, Brushes.Black, exis + 8, yPos - 3);
                //}
                //else if (calibre.Replace("D", "").Length.Equals(4))
                //{
                //    e.Graphics.DrawString(calibre.Replace("D", ""), desFont3, Brushes.Black, exis - 4, yPos - 3);
                //}
                //else if (calibre.Replace("D", "").Length.Equals(1))
                //{
                //    e.Graphics.DrawString(calibre.Replace("D", ""), new Font("Arial Black", 35, FontStyle.Bold), Brushes.Black, exis + 60, yPos - 3);
                //}

                e.Graphics.DrawString("CSP:", desFont, Brushes.Black, 20, yPos + 72);
                e.Graphics.DrawString("PACKING BY / EMPACADORA", new Font("Arial", 3, FontStyle.Bold), Brushes.Black, 7, yPos + 86);
                e.Graphics.DrawString("176227", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 0, yPos + 90);
                e.Graphics.DrawString("TOWNSHIP:", prFont3, Brushes.Black, 80, yPos + 74);
                //e.Graphics.DrawString("SOCIEDAD PACKING SERVICE INGENIERIA", prFont, Brushes.Black, 70, yPos + 86);
                e.Graphics.DrawString("PROVINCE:", prFont3, Brushes.Black, 80, yPos + 88);
                e.Graphics.DrawString("REGION: ", prFont3, Brushes.Black, 80, yPos + 102);
                e.Graphics.DrawString("CURICO", prFont3, Brushes.Black, 145, yPos + 74);
                e.Graphics.DrawString("CURICO", prFont3, Brushes.Black, 145, yPos + 88);
                e.Graphics.DrawString("VII", prFont3, Brushes.Black, 145, yPos + 102);
                //e.Graphics.DrawString(provincia.ToUpper()+" - "+comuna.ToUpper(), prFont, Brushes.Black, 70, yPos + 96);
                //e.Graphics.DrawString("FDA:", prFont, Brushes.Black, 0, yPos + 106);
                //e.Graphics.DrawString(fda, prFont, Brushes.Black, 70, yPos + 106);

                //e.Graphics.DrawString("CAT-1", new Font("Arial", 19, FontStyle.Bold), Brushes.Black, 15, yPos + 135);
                e.Graphics.DrawString("CLASS 1 PRODUCE OF CHILE", prFont, Brushes.Black, 5, yPos + 170);
                //e.Graphics.DrawString("EXPORTED BY: ______", prFont2, Brushes.Black, 182, yPos + 136);
                //e.Graphics.DrawString("RUT: xx.xxx.xxx-x     CSE: xxxxx", prFont2, Brushes.Black, 212, yPos + 145);
                //e.Graphics.DrawString("FUNDO xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", prFont2, Brushes.Black, 180, yPos + 154);
                //
                //if (calibre.Equals("TC")) { e.Graphics.DrawString("COMERCIAL", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 220, yPos + 85); }
                //else { e.Graphics.DrawString("CAT-1", new Font("Arial", 10, FontStyle.Bold), Brushes.Black, 235, yPos + 85); }
                e.Graphics.DrawString("EXPORTED BY:", new Font("Arial", 8, FontStyle.Bold), Brushes.Black, 245, yPos + 120);
                ConexionDB getexp        = new ConexionDB();
                string     exp_abreviada = ExportadorBox.Text;
                exp_abreviada = exp_abreviada.Replace("EXPORTADORA", "EXP.");
                exp_abreviada = exp_abreviada.Replace("EXPORTADOR", "EXP.");
                exp_abreviada = exp_abreviada.Replace("COMERCIAL", "COM.");
                exp_abreviada = exp_abreviada.Replace("COMERCIALIZADORA", "COM.");
                exp_abreviada = exp_abreviada.Replace("PRODUCTOR", "PROD.");
                e.Graphics.DrawString(exp_abreviada, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, 245, yPos + 140);
                getexp.Cerrar();
                e.Graphics.DrawString("CSE:", new Font("Arial", 10, FontStyle.Bold), Brushes.Black, 245, yPos + 160);
                ConexionDB obtCSE = new ConexionDB();
                e.Graphics.DrawString(obtCSE.ObtenerNumeroCSE(ExportadorBox.Text), new Font("Arial", 10, FontStyle.Bold), Brushes.Black, 285, yPos + 160);
                obtCSE.Cerrar();
                //e.Graphics.DrawString("TURNO:", prFont2, Brushes.Black, 302, yPos + 74);
                //e.Graphics.DrawString(turno.ToString(), prFont2, Brushes.Black, 332, yPos + 74);
                //e.Graphics.DrawString("LINEA:", prFont2, Brushes.Black, 303, yPos + 85);
                //e.Graphics.DrawString("1", prFont2, Brushes.Black, 332, yPos + 85);
                e.Graphics.DrawString("SALIDA", new Font("Arial", 5, FontStyle.Bold), Brushes.Black, 317, yPos + 74);
                Random rnd2   = new Random();
                int    salida = rnd2.Next(1, 28);
                int    impre  = 1;
                if (salida.Equals(1) || salida.Equals(2))
                {
                    impre = 1;
                }
                if (salida.Equals(3) || salida.Equals(4))
                {
                    impre = 2;
                }
                if (salida.Equals(5) || salida.Equals(6))
                {
                    impre = 3;
                }
                if (salida.Equals(7) || salida.Equals(8))
                {
                    impre = 4;
                }
                if (salida.Equals(9) || salida.Equals(10))
                {
                    impre = 5;
                }
                if (salida.Equals(11) || salida.Equals(12))
                {
                    impre = 6;
                }
                if (salida.Equals(13) || salida.Equals(14))
                {
                    impre = 7;
                }
                if (salida.Equals(15) || salida.Equals(16))
                {
                    impre = 8;
                }

                if (salida.Equals(17) || salida.Equals(18))
                {
                    impre = 9;
                }
                if (salida.Equals(19) || salida.Equals(20))
                {
                    impre = 10;
                }
                if (salida.Equals(21) || salida.Equals(22))
                {
                    impre = 11;
                }
                if (salida.Equals(23) || salida.Equals(24))
                {
                    impre = 12;
                }
                if (salida.Equals(25) || salida.Equals(26))
                {
                    impre = 13;
                }
                if (salida.Equals(27) || salida.Equals(28))
                {
                    impre = 14;
                }

                if (salida > 9)
                {
                    e.Graphics.DrawString(salida.ToString(), new Font("Arial", 6, FontStyle.Bold), Brushes.Black, 325, yPos + 82);
                }
                else
                {
                    e.Graphics.DrawString(salida.ToString(), new Font("Arial", 6, FontStyle.Bold), Brushes.Black, 327, yPos + 82);
                }


                e.Graphics.DrawString("IMPRESORA", new Font("Arial", 5, FontStyle.Bold), Brushes.Black, 310, yPos + 96);

                if (impre > 9)
                {
                    e.Graphics.DrawString(impre.ToString(), new Font("Arial", 6, FontStyle.Bold), Brushes.Black, 325, yPos + 104);
                }
                else
                {
                    e.Graphics.DrawString(impre.ToString(), new Font("Arial", 6, FontStyle.Bold), Brushes.Black, 329, yPos + 104);
                }
                //e.Graphics.DrawString("SALIDA:", prFont2, Brushes.Black, 302, yPos + 96);
                //e.Graphics.DrawString(saposalida, prFont2, Brushes.Black, 332, yPos + 96);
                //e.Graphics.DrawString("IMP:", prFont2, Brushes.Black, 302, yPos + 107);
                //if(impresora.Length > 10) { e.Graphics.DrawString(impresora.Substring(9, 2), prFont2, Brushes.Black, 332, yPos + 107); }
                //else { e.Graphics.DrawString(impresora.Substring(9, 1), prFont2, Brushes.Black, 332, yPos + 107); }

                //'codigo vertical     CODE-128
                //e.Graphics.DrawImage(img, 343, yPos + 15);

                //'codigo horizontal   EAN13
                //e.Graphics.DrawImage(img2, 115, yPos + 118);

                Font prFontx = new Font("Arial", 6, FontStyle.Bold);

                //SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
                //e.Graphics.FillRectangle(myBrush, new Rectangle(153, yPos + 172, 54, 10));
                //e.Graphics.DrawString(numcode, prFont, Brushes.Black, 153, yPos + 173);

                //'GUARDO LA ETIQUETA EN LA BASE DE DATOS

                string cla = "";
                //if (calibre.Equals("TC"))
                //{
                //    cla = "COM";
                //}
                //else
                //{
                //    if (calibre.Contains("D")) { cla = "DARK"; }
                //    else { cla = "LIGHT"; }
                //}
                //if (calibre.Equals("L")) { cla = "LIGHT"; }
                //if (calibre.Equals("LD")) { cla = "DARK"; }
                //if (calibre.Equals("XL")) { cla = "LIGHT"; }
                //if (calibre.Equals("XLD")) { cla = "DARK"; }
                //if (calibre.Equals("J")) { cla = "LIGHT"; }
                //if (calibre.Equals("JD")) { cla = "DARK"; }
                //if (calibre.Equals("SJ")) { cla = "LIGHT"; }
                //if (calibre.Equals("SJD")) { cla = "DARK"; }
                //if (calibre.Equals("P")) { cla = "LIGHT"; }
                //if (calibre.Equals("PD")) { cla = "DARK"; }
                //if (calibre.Equals("SP")) { cla = "LIGHT"; }
                //if (calibre.Equals("SPD")) { cla = "DARK"; }
                //if (calibre.Equals("SG")) { cla = "LIGHT"; }
                //if (calibre.Equals("SGD")) { cla = "DARK"; }

                //sql_masivo += "INSERT INTO etiquetado_system.dbo.etiqueta(codigo_interno, codigo_ean13, especie, variedad, clasificacion, calibre, embalaje, productor, categoria, lote_huerto, proceso_n, cuartel, salida, tipo_frio, turno, fecha, fda, ggn, paso1, codigo_tarja, cuadrilla) "
                //    + "VALUES('" + numcode + "', '" + numcode + "', 'APPLES', '" + variedad.ToUpper() + "', '" + cla + "', '" + calibre.Replace("D", "").ToUpper() + "', '" + embalaje.ToUpper() + "', '" + productor + "', 'CAT-1', '" + lote_huerto + "', '" + proceso_n + "', NULL, 'Salida " + salida + "', 'AR', 1, '" + FechaBox.Value.ToString("yyyy-MM-dd") + "', '00', '00', 0, NULL, NULL);";

                //ConexionDB getiq = new ConexionDB();
                //getiq.GuardarEtiqueta(numcode, "CHERRIES", variedad.ToUpper(), cla, calibre.Replace("D", "").ToUpper(), embalaje.ToUpper(), productor, "CAT-1", lote_huerto, proceso_n, "Salida " + salidaa, "AR", turno, FechaBox.Value.ToString("yyyy-MM-dd"), "00", "00");
                //getiq.Cerrar();
                //'IMPRIMO LINEAS DEL DISEÑO
                Pen blackPen1 = new Pen(Color.Black, 1);
                Pen blackPen2 = new Pen(Color.Black, 2);
                //'horizontales
                e.Graphics.DrawLine(blackPen2, new Point(295, yPos + 22), new Point(370, yPos + 22));
                e.Graphics.DrawLine(blackPen2, new Point(295, yPos + 70), new Point(370, yPos + 70));
                e.Graphics.DrawLine(blackPen2, new Point(0, yPos + 70), new Point(295, yPos + 70));
                e.Graphics.DrawLine(blackPen2, new Point(0, yPos + 115), new Point(370, yPos + 115));

                //'verticales
                //e.Graphics.DrawLine(blackPen2, new Point(160, yPos + 116), new Point(160, yPos + 22));
                e.Graphics.DrawLine(blackPen2, new Point(295, yPos + 116), new Point(295, yPos + 0));
                e.Graphics.DrawLine(blackPen2, new Point(370, yPos + 116), new Point(370, yPos + 0));
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, "Hubo un error en generar el codigo de barra. " + ex.ToString(), "INFO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //' indicamos que ya no hay nada más que imprimir
            //' (el valor predeterminado de esta propiedad es False)
            e.HasMorePages = false;
        }
예제 #16
0
 private int GetWeekOfYear(DateTime date)
 {
     return(calendar.GetWeekOfYear(date, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Monday));
 }
예제 #17
0
        public override Task DoWork(CancellationToken cancellationToken)
        {
            var scope      = scopeFactory.CreateScope();
            var dbContext  = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
            int intIdMulta = 0;

            ParametrosController    par   = new ParametrosController(dbContext);
            ActionResult <DateTime> time1 = par.mtdObtenerFechaMexico();
            DateTime time = time1.Value;

            //DateTime time = DateTime.Now;

            try
            {
                double dblTotalXDiaIos            = 0;
                double dblTotalXDiaAndriod        = 0;
                int    intTransIos                = 0;
                int    intTransAndriod            = 0;
                int    intAutosSemAnteriorIos     = 0;
                int    intAutosSemAnteriorAndroid = 0;
                double totalIngresos              = 0;
                int    intNoSemanaActual          = 0;
                /////////////
                Double int_sem_por_ios           = 0;
                Double int_sem_autos_por_ios     = 0;
                Double dec_sem_por_ios           = 0;
                Double int_sem_por_andriod       = 0;
                Double int_sem_autos_por_andriod = 0;
                Double dec_sem_por_andriod       = 0;
                Double int_sem_por_ant           = 0;
                Double dec_sem_por_total         = 0;
                /////////
                // Double dec_sem_por_total = 0;


                DateTime dia = time;

                var concesiones = dbContext.tbconcesiones.ToList();

                foreach (var concns in concesiones)
                {
                    System.Globalization.CultureInfo norwCulture = System.Globalization.CultureInfo.CreateSpecificCulture("es");
                    System.Globalization.Calendar    cal         = norwCulture.Calendar;
                    intNoSemanaActual = cal.GetWeekOfYear(dia, norwCulture.DateTimeFormat.CalendarWeekRule, norwCulture.DateTimeFormat.FirstDayOfWeek);
                    int       inNoSemAnterior = intNoSemanaActual - 1;
                    DayOfWeek weekStart       = DayOfWeek.Monday; // or Sunday, or whenever
                    DateTime  startingDate    = time;

                    //while (startingDate.DayOfWeek != weekStart)
                    //    startingDate = startingDate.AddDays(-1);

                    // DateTime previousWeekStart = startingDate.AddDays(-7);
                    DateTime previousWeekStart = startingDate;
                    DateTime previousWeekEnd   = startingDate.AddDays(-5);

                    //Para obtener dato de los autos del dia anterior
                    DateTime diaanterior        = dia.AddDays(-1);
                    var      resumenSemAnterior = dbContext.tbresumensemanal.FirstOrDefault(x => x.int_semana == inNoSemAnterior && x.int_id_consecion == concns.id);


                    if (resumenSemAnterior != null)
                    {
                        intAutosSemAnteriorIos     = resumenSemAnterior.int_sem_autos_ios;
                        intAutosSemAnteriorAndroid = resumenSemAnterior.int_sem_autos_andriod;

                        var registrosDeSem = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).Sum(i => i.int_ios);

                        int    sumaTransSemIos     = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).Sum(i => i.int_ios);
                        int    sumaTransSemAndroid = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).Sum(i => i.int_andriod);
                        int    sumaAutosIos        = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).Sum(i => i.int_autos_ios);
                        int    sumaAutosAndriod    = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).Sum(i => i.int_autos_andriod);
                        double dblingrSemaIOs      = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).Sum(i => i.dec_ios);
                        double dblingrSemaAndroid  = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).Sum(i => i.dec_andriod);


                        int    totalAutos    = sumaAutosAndriod + sumaAutosIos;
                        int    transTotales  = sumaTransSemIos + sumaTransSemAndroid;
                        double dblIngTotales = dblingrSemaIOs + dblingrSemaAndroid;
                        if (resumenSemAnterior.int_sem_ios != 0)
                        {
                            int_sem_por_ios = (((double)sumaTransSemIos / (double)resumenSemAnterior.int_sem_ios) - 1);
                            int_sem_por_ios = int_sem_por_ios * 100;
                        }
                        else
                        {
                            if (sumaTransSemIos > 0)
                            {
                                int_sem_por_ios = 100;
                            }
                        }

                        if (resumenSemAnterior.int_sem_autos_ios != 0)
                        {
                            int_sem_autos_por_ios = (((double)sumaAutosIos / (double)resumenSemAnterior.int_sem_autos_ios) - 1);
                            int_sem_autos_por_ios = int_sem_autos_por_ios * 100;
                        }
                        else
                        {
                            if (sumaAutosIos > 0)
                            {
                                int_sem_autos_por_ios = 100;
                            }
                        }

                        if (resumenSemAnterior.dec_sem_ios != 0)
                        {
                            dec_sem_por_ios = ((dblingrSemaIOs / resumenSemAnterior.dec_sem_ios) - 1);
                            dec_sem_por_ios = dec_sem_por_ios * 100;
                        }
                        else
                        {
                            if (dblingrSemaIOs > 0)
                            {
                                dec_sem_por_ios = 100;
                            }
                        }
                        if (resumenSemAnterior.int_sem_andriod != 0)
                        {
                            int_sem_por_andriod = (((double)sumaTransSemAndroid / (double)resumenSemAnterior.int_sem_andriod) - 1);
                            int_sem_por_andriod = int_sem_por_andriod * 100;
                        }
                        else
                        {
                            int_sem_autos_por_andriod = (((double)sumaAutosIos / (double)resumenSemAnterior.int_sem_autos_andriod) - 1);
                            int_sem_autos_por_andriod = int_sem_autos_por_andriod * 100;
                        }
                        if (resumenSemAnterior.dec_sem_andriod != 0)
                        {
                            dec_sem_por_andriod = ((dblingrSemaAndroid / resumenSemAnterior.dec_sem_andriod) - 1);
                            dec_sem_por_andriod = dec_sem_por_andriod * 100;
                        }
                        else
                        {
                            if (dblingrSemaAndroid > 0)
                            {
                                dec_sem_por_andriod = 100;
                            }
                        }
                        if (resumenSemAnterior.int_sem_total != 0)
                        {
                            int_sem_por_ant = (((double)transTotales / (double)resumenSemAnterior.int_sem_total) - 1);
                            int_sem_por_ant = int_sem_por_ant * 100;
                        }
                        else
                        {
                            if (transTotales > 0)
                            {
                                int_sem_por_ant = 100;
                            }
                        }
                        if (resumenSemAnterior.dec_sem_total != 0)
                        {
                            dec_sem_por_total = ((dblIngTotales / resumenSemAnterior.dec_sem_total) - 1);
                            dec_sem_por_total = dec_sem_por_total * 100;
                        }
                        else
                        {
                            if (dblIngTotales > 0)
                            {
                                dec_sem_por_total = 100;
                            }
                        }



                        var strategy = dbContext.Database.CreateExecutionStrategy();

                        strategy.Execute(() =>
                        {
                            using (IDbContextTransaction transaction = dbContext.Database.BeginTransaction())
                            {
                                try
                                {
                                    dbContext.tbresumensemanal.Add(new ResumenSemanal()
                                    {
                                        int_id_consecion          = concns.id,
                                        dtm_fecha_inicio          = previousWeekStart,
                                        dtm_fecha_fin             = previousWeekEnd,
                                        int_semana                = intNoSemanaActual,
                                        int_anio                  = time.Year,
                                        int_semana_ant            = resumenSemAnterior.int_semana,
                                        int_sem_ios               = sumaTransSemIos,
                                        int_sem_ant_ios           = resumenSemAnterior.int_sem_ios,
                                        int_sem_por_ios           = int_sem_por_ios,
                                        int_sem_autos_ios         = sumaAutosIos,
                                        int_sem_autos_ant_ios     = resumenSemAnterior.int_sem_autos_ios,
                                        int_sem_autos_por_ios     = int_sem_autos_por_ios,
                                        dec_sem_ios               = dblingrSemaIOs,
                                        dec_sem_ant_ios           = resumenSemAnterior.dec_sem_ios,
                                        dec_sem_por_ios           = dec_sem_por_ios,
                                        int_sem_andriod           = sumaTransSemAndroid,
                                        int_sem_ant_andriod       = resumenSemAnterior.int_sem_andriod,
                                        int_sem_por_andriod       = int_sem_por_andriod,
                                        int_sem_autos_andriod     = sumaAutosAndriod,
                                        int_sem_autos_ant_andriod = resumenSemAnterior.int_sem_autos_andriod,
                                        int_sem_autos_por_andriod = int_sem_autos_por_andriod,
                                        int_sem_total_autos       = totalAutos,
                                        dec_sem_andriod           = dblingrSemaAndroid,
                                        dec_sem_ant_andriod       = resumenSemAnterior.dec_sem_andriod,
                                        dec_sem_por_andriod       = dec_sem_por_andriod,
                                        int_sem_total             = transTotales,
                                        int_sem_total_ant         = resumenSemAnterior.int_sem_total,
                                        int_sem_por_ant           = int_sem_por_ant,
                                        dec_sem_total             = dblIngTotales,
                                        dec_sem_total_ant         = resumenSemAnterior.dec_sem_total,
                                        dec_sem_por_total         = dec_sem_por_total
                                    });
                                    dbContext.SaveChanges();
                                    transaction.Commit();
                                }
                                catch (Exception)
                                {
                                    transaction.Rollback();
                                }
                            }
                        });

                        dblTotalXDiaIos            = 0;
                        dblTotalXDiaAndriod        = 0;
                        intTransIos                = 0;
                        intTransAndriod            = 0;
                        intAutosSemAnteriorIos     = 0;
                        intAutosSemAnteriorAndroid = 0;
                        totalIngresos              = 0;
                        intNoSemanaActual          = 0;
                        /////////////
                        int_sem_por_ios           = 0;
                        int_sem_autos_por_ios     = 0;
                        dec_sem_por_ios           = 0;
                        int_sem_por_andriod       = 0;
                        int_sem_autos_por_andriod = 0;
                        dec_sem_por_andriod       = 0;
                        int_sem_por_ant           = 0;
                        dec_sem_por_total         = 0;
                    }
                    else
                    {
                        // intAutosSemAnteriorIos = resumenSemAnterior.int_sem_autos_ios;
                        //intAutosSemAnteriorAndroid = resumenSemAnterior.int_sem_autos_andriod;

                        var registrosDeSem = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekEnd.Date && x.dtm_fecha.Date <= previousWeekStart.Date && x.int_id_consecion == concns.id).Sum(i => i.int_ios);

                        int    sumaTransSemIos     = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekEnd.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).Sum(i => i.int_ios);
                        int    sumaTransSemAndroid = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekEnd.Date && x.dtm_fecha.Date <= previousWeekStart.Date && x.int_id_consecion == concns.id).Sum(i => i.int_andriod);
                        int    sumaAutosIos        = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekEnd.Date && x.dtm_fecha.Date <= previousWeekStart.Date && x.int_id_consecion == concns.id).Sum(i => i.int_autos_ios);
                        int    sumaAutosAndriod    = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekEnd.Date && x.dtm_fecha.Date <= previousWeekStart.Date && x.int_id_consecion == concns.id).Sum(i => i.int_autos_andriod);
                        double dblingrSemaIOs      = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekEnd.Date && x.dtm_fecha.Date <= previousWeekStart.Date && x.int_id_consecion == concns.id).Sum(i => i.dec_ios);
                        double dblingrSemaAndroid  = dbContext.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekEnd.Date && x.dtm_fecha.Date <= previousWeekStart.Date && x.int_id_consecion == concns.id).Sum(i => i.dec_andriod);


                        int    totalAutos    = sumaAutosAndriod + sumaAutosIos;
                        int    transTotales  = sumaTransSemIos + sumaTransSemAndroid;
                        double dblIngTotales = dblingrSemaIOs + dblingrSemaAndroid;


                        if (sumaTransSemIos > 0)
                        {
                            int_sem_por_ios = 100;
                        }

                        if (sumaAutosIos > 0)
                        {
                            int_sem_autos_por_ios = 100;
                        }

                        if (dblingrSemaIOs > 0)
                        {
                            dec_sem_por_ios = 100;
                        }

                        if (sumaTransSemAndroid > 0)
                        {
                            int_sem_por_andriod = 100;
                        }

                        if (sumaAutosIos > 0)
                        {
                            int_sem_autos_por_andriod = 100;
                        }

                        if (dblingrSemaAndroid > 0)
                        {
                            dec_sem_por_andriod = 100;
                        }

                        if (transTotales > 0)
                        {
                            int_sem_por_ant = 100;
                        }

                        if (dblIngTotales > 0)
                        {
                            dec_sem_por_total = 100;
                        }


                        var strategy = dbContext.Database.CreateExecutionStrategy();

                        strategy.Execute(() =>
                        {
                            using (IDbContextTransaction transaction = dbContext.Database.BeginTransaction())
                            {
                                try
                                {
                                    dbContext.tbresumensemanal.Add(new ResumenSemanal()
                                    {
                                        int_id_consecion          = concns.id,
                                        dtm_fecha_inicio          = previousWeekEnd,
                                        dtm_fecha_fin             = previousWeekStart,
                                        int_semana                = intNoSemanaActual,
                                        int_anio                  = time.Year,
                                        int_semana_ant            = inNoSemAnterior,
                                        int_sem_ios               = sumaTransSemIos,
                                        int_sem_ant_ios           = 0,
                                        int_sem_por_ios           = int_sem_por_ios,
                                        int_sem_autos_ios         = sumaAutosIos,
                                        int_sem_autos_ant_ios     = 0,
                                        int_sem_autos_por_ios     = int_sem_autos_por_ios,
                                        dec_sem_ios               = dblingrSemaIOs,
                                        dec_sem_ant_ios           = 0.00,
                                        dec_sem_por_ios           = dec_sem_por_ios,
                                        int_sem_andriod           = sumaTransSemAndroid,
                                        int_sem_ant_andriod       = 0,
                                        int_sem_por_andriod       = int_sem_por_andriod,
                                        int_sem_autos_andriod     = sumaAutosAndriod,
                                        int_sem_autos_ant_andriod = 0,
                                        int_sem_autos_por_andriod = int_sem_autos_por_andriod,
                                        int_sem_total_autos       = totalAutos,
                                        dec_sem_andriod           = dblingrSemaAndroid,
                                        dec_sem_ant_andriod       = 0.00,
                                        dec_sem_por_andriod       = dec_sem_por_andriod,
                                        int_sem_total             = transTotales,
                                        int_sem_total_ant         = 0,
                                        int_sem_por_ant           = int_sem_por_ant,
                                        dec_sem_total             = dblIngTotales,
                                        dec_sem_total_ant         = 0.00,
                                        dec_sem_por_total         = dec_sem_por_total,
                                    });;
                                    dbContext.SaveChanges();
                                    transaction.Commit();
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        });


                        dblTotalXDiaIos            = 0;
                        dblTotalXDiaAndriod        = 0;
                        intTransIos                = 0;
                        intTransAndriod            = 0;
                        intAutosSemAnteriorIos     = 0;
                        intAutosSemAnteriorAndroid = 0;
                        totalIngresos              = 0;
                        intNoSemanaActual          = 0;
                        /////////////
                        int_sem_por_ios           = 0;
                        int_sem_autos_por_ios     = 0;
                        dec_sem_por_ios           = 0;
                        int_sem_por_andriod       = 0;
                        int_sem_autos_por_andriod = 0;
                        dec_sem_por_andriod       = 0;
                        int_sem_por_ant           = 0;
                        dec_sem_por_total         = 0;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(Task.CompletedTask);
        }
예제 #18
0
        public async Task <ActionResult> mtdInsertarResumenSemanal()
        {
            try
            {
                double   dblTotalXDiaIos            = 0;
                double   dblTotalXDiaAndriod        = 0;
                int      intTransIos                = 0;
                int      intTransAndriod            = 0;
                int      intAutosSemAnteriorIos     = 0;
                int      intAutosSemAnteriorAndroid = 0;
                double   totalIngresos              = 0;
                int      intNoSemanaActual          = 0;
                DateTime dia = DateTime.Now;

                var concesiones = await context.tbconcesiones.ToListAsync();

                foreach (var concns in concesiones)
                {
                    System.Globalization.CultureInfo norwCulture = System.Globalization.CultureInfo.CreateSpecificCulture("es");
                    System.Globalization.Calendar    cal         = norwCulture.Calendar;
                    intNoSemanaActual = cal.GetWeekOfYear(dia, norwCulture.DateTimeFormat.CalendarWeekRule, norwCulture.DateTimeFormat.FirstDayOfWeek);
                    int       inNoSemAnterior = intNoSemanaActual - 1;
                    DayOfWeek weekStart       = DayOfWeek.Monday; // or Sunday, or whenever
                    DateTime  startingDate    = DateTime.Today;

                    while (startingDate.DayOfWeek != weekStart)
                    {
                        startingDate = startingDate.AddDays(-1);
                    }

                    DateTime previousWeekStart = startingDate.AddDays(-7);
                    DateTime previousWeekEnd   = startingDate.AddDays(-2);

                    //Para obtener dato de los autos del dia anterior
                    DateTime diaanterior        = dia.AddDays(-1);
                    var      resumenSemAnterior = await context.tbresumensemanal.FirstOrDefaultAsync(x => x.int_semana == inNoSemAnterior && x.int_id_consecion == concns.id);


                    if (resumenSemAnterior != null)
                    {
                        intAutosSemAnteriorIos     = resumenSemAnterior.int_sem_autos_ios;
                        intAutosSemAnteriorAndroid = resumenSemAnterior.int_sem_autos_andriod;

                        var registrosDeSem = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.int_ios);

                        int sumaTransSemIos = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.int_ios);

                        int sumaTransSemAndroid = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.int_andriod);

                        int sumaAutosIos = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.int_autos_ios);

                        int sumaAutosAndriod = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.int_autos_andriod);

                        double dblingrSemaIOs = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.dec_ios);

                        double dblingrSemaAndroid = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.dec_andriod);


                        int    totalAutos    = sumaAutosAndriod + sumaAutosIos;
                        int    transTotales  = sumaTransSemIos + sumaTransSemAndroid;
                        double dblIngTotales = dblingrSemaIOs + dblingrSemaAndroid;
                        context.tbresumensemanal.Add(new ResumenSemanal()
                        {
                            int_id_consecion          = concns.id,
                            dtm_fecha_inicio          = previousWeekStart,
                            dtm_fecha_fin             = previousWeekEnd,
                            int_semana                = intNoSemanaActual,
                            int_anio                  = DateTime.Now.Year,
                            int_semana_ant            = resumenSemAnterior.int_semana,
                            int_sem_ios               = sumaTransSemIos,
                            int_sem_ant_ios           = resumenSemAnterior.int_sem_ios,
                            int_sem_por_ios           = ((sumaTransSemIos / resumenSemAnterior.int_sem_ios) - 1),
                            int_sem_autos_ios         = sumaAutosIos,
                            int_sem_autos_ant_ios     = resumenSemAnterior.int_sem_autos_ios,
                            int_sem_autos_por_ios     = ((sumaAutosIos / resumenSemAnterior.int_sem_autos_ios) - 1),
                            dec_sem_ios               = dblingrSemaIOs,
                            dec_sem_ant_ios           = resumenSemAnterior.dec_sem_ios,
                            dec_sem_por_ios           = ((dblingrSemaIOs / resumenSemAnterior.dec_sem_ios) - 1),
                            int_sem_andriod           = sumaTransSemAndroid,
                            int_sem_ant_andriod       = resumenSemAnterior.int_sem_andriod,
                            int_sem_por_andriod       = ((sumaTransSemAndroid / resumenSemAnterior.int_sem_andriod) - 1),
                            int_sem_autos_andriod     = sumaAutosAndriod,
                            int_sem_autos_ant_andriod = resumenSemAnterior.int_sem_autos_andriod,
                            int_sem_autos_por_andriod = ((sumaAutosIos / resumenSemAnterior.int_sem_autos_andriod) - 1),
                            int_sem_total_autos       = totalAutos,
                            dec_sem_andriod           = dblingrSemaAndroid,
                            dec_sem_ant_andriod       = resumenSemAnterior.dec_sem_andriod,
                            dec_sem_por_andriod       = ((dblingrSemaAndroid / resumenSemAnterior.dec_sem_andriod) - 1),
                            int_sem_total             = transTotales,
                            int_sem_total_ant         = resumenSemAnterior.int_sem_total,
                            int_sem_por_ant           = ((transTotales / resumenSemAnterior.int_sem_total) - 1),
                            dec_sem_total             = dblIngTotales,
                            dec_sem_total_ant         = resumenSemAnterior.dec_sem_total,
                            dec_sem_por_total         = ((dblIngTotales / resumenSemAnterior.dec_sem_total) - 1),
                        });;
                        context.SaveChanges();
                        intAutosSemAnteriorIos     = 0;
                        intAutosSemAnteriorAndroid = 0;
                    }
                    else
                    {
                        intAutosSemAnteriorIos     = resumenSemAnterior.int_sem_autos_ios;
                        intAutosSemAnteriorAndroid = resumenSemAnterior.int_sem_autos_andriod;

                        var registrosDeSem = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.int_ios);

                        int sumaTransSemIos = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.int_ios);

                        int sumaTransSemAndroid = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.int_andriod);

                        int sumaAutosIos = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.int_autos_ios);

                        int sumaAutosAndriod = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.int_autos_andriod);

                        double dblingrSemaIOs = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.dec_ios);

                        double dblingrSemaAndroid = await context.tbresumendiario.Where(x => x.dtm_fecha.Date >= previousWeekStart.Date && x.dtm_fecha.Date <= previousWeekEnd.Date && x.int_id_consecion == concns.id).SumAsync(i => i.dec_andriod);


                        int    totalAutos    = sumaAutosAndriod + sumaAutosIos;
                        int    transTotales  = sumaTransSemIos + sumaTransSemAndroid;
                        double dblIngTotales = dblingrSemaIOs + dblingrSemaAndroid;
                        context.tbresumensemanal.Add(new ResumenSemanal()
                        {
                            int_id_consecion          = concns.id,
                            dtm_fecha_inicio          = previousWeekStart,
                            dtm_fecha_fin             = previousWeekEnd,
                            int_semana                = intNoSemanaActual,
                            int_anio                  = DateTime.Now.Year,
                            int_semana_ant            = inNoSemAnterior,
                            int_sem_ios               = sumaTransSemIos,
                            int_sem_ant_ios           = 0,
                            int_sem_por_ios           = 100,
                            int_sem_autos_ios         = sumaAutosIos,
                            int_sem_autos_ant_ios     = 0,
                            int_sem_autos_por_ios     = 100,
                            dec_sem_ios               = dblingrSemaIOs,
                            dec_sem_ant_ios           = 0,
                            dec_sem_por_ios           = 100,
                            int_sem_andriod           = sumaTransSemAndroid,
                            int_sem_ant_andriod       = 0,
                            int_sem_por_andriod       = 100,
                            int_sem_autos_andriod     = sumaAutosAndriod,
                            int_sem_autos_ant_andriod = 0,
                            int_sem_autos_por_andriod = 100,
                            int_sem_total_autos       = totalAutos,
                            dec_sem_andriod           = dblingrSemaAndroid,
                            dec_sem_ant_andriod       = 0,
                            dec_sem_por_andriod       = 100,
                            int_sem_total             = transTotales,
                            int_sem_total_ant         = 0,
                            int_sem_por_ant           = 100,
                            dec_sem_total             = dblIngTotales,
                            dec_sem_total_ant         = resumenSemAnterior.dec_sem_total,
                            dec_sem_por_total         = 100,
                        });;
                        context.SaveChanges();
                        intAutosSemAnteriorIos     = 0;
                        intAutosSemAnteriorAndroid = 0;
                    }
                }

                return(Json(new { token = "OK" }));
            }
            catch (Exception ex)
            {
                return(Json(new { token = ex.Message }));
            }
        }
예제 #19
0
        public Image DrawSchema(out CoordsMaps coordsMaps, int colHeight, DateTime startDate, DateTime endDate, RowsFlags Pflags)
        {
            System.Globalization.CultureInfo UICulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
            System.Globalization.Calendar    cal       = UICulture.Calendar;
            ganttStart = startDate;
            ganttEnd   = endDate;

            int days     = endDate.Subtract(startDate).Days;
            int rowCount = 0;

            if ((Pflags & RowsFlags.NoYears) != RowsFlags.NoYears)
            {
                yearRow = (rowCount++) * rowsSize + top;
            }
            int startYear    = startDate.Year;
            int firstColYear = 0;

            if ((Pflags & RowsFlags.NoMonths) != RowsFlags.NoMonths)
            {
                monthRow = (rowCount++) * rowsSize + top;
            }
            int startMonth    = startDate.Month;
            int firstColMonth = 0;

            if ((Pflags & RowsFlags.NoWeeks) != RowsFlags.NoWeeks)
            {
                weekRow = (rowCount++) * rowsSize + top;
            }
            int startWeek    = cal.GetWeekOfYear(startDate, UICulture.DateTimeFormat.CalendarWeekRule, UICulture.DateTimeFormat.FirstDayOfWeek);
            int firstColWeek = 0;

            if ((Pflags & RowsFlags.NoDays) != RowsFlags.NoDays)
            {
                dayRow = (rowCount++) * rowsSize + top;
            }
            this.ganttHeight = colHeight + dayRow + 1;
            Image img = new Bitmap(days * dayColumnSize + 1, this.ganttHeight);

            g = Graphics.FromImage(img);
            g.Clear(Color.White);

            SolidBrush brush        = new SolidBrush(Color.Black);
            SolidBrush dayBrush     = new SolidBrush(Color.LightGray);
            SolidBrush weekendBrush = new SolidBrush(Color.DarkGray);

            sf = new StringFormat(StringFormatFlags.NoClip | StringFormatFlags.NoWrap | StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.MeasureTrailingSpaces);
            Font yearFont = FontToFitVertical(new FontFamily("Arial"), FontStyle.Regular, rowsSize, sf);

            monthFont    = FontToFitVertical(new FontFamily("Arial"), FontStyle.Regular, rowsSize, sf);
            descFont     = FontToFitVertical(new FontFamily("Arial"), FontStyle.Regular, rowsSize, sf);
            descFontBold = FontToFitVertical(new FontFamily("Arial"), FontStyle.Bold, rowsSize, sf);
            monthDayFont = FontToFitHorizontal(new FontFamily("Arial"), FontStyle.Regular, dayColumnSize, sf);
            Pen pen = new Pen(Color.DarkGray, 1F);

            sf.Alignment        = StringAlignment.Center;
            sf.LineAlignment    = StringAlignment.Center;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            int        dayLeft = 0;
            Rectangle  ra      = new Rectangle();
            CoordsMaps cm      = new CoordsMaps();

            for (int i = 0; i <= days; i++)
            {
                int      currentPixel = i * dayColumnSize;
                DateTime todayDate    = cal.AddDays(startDate, i);
                if (yearRow != -1 && (todayDate.Year != startYear || i == days))
                {
                    ra = new Rectangle(left + firstColYear, yearRow, currentPixel - firstColYear, rowsSize);
                    g.DrawRectangle(pen, ra);
                    g.DrawString(startYear.ToString(), monthFont, brush, ra, sf);
                    cm.Add(new CoordsMap(RowTypes.Years, ra, startYear));
                    startYear    = todayDate.Year;
                    firstColYear = currentPixel;
                }
                if (monthRow != -1 && (todayDate.Day == 1 || i == days))
                {
                    ra = new Rectangle(left + firstColMonth, monthRow, currentPixel - firstColMonth, rowsSize);
                    string month = UICulture.DateTimeFormat.GetMonthName(startMonth);
                    if (yearRow == -1)
                    {
                        month += " " + todayDate.Year;
                    }
                    g.DrawRectangle(pen, ra);
                    if (g.MeasureString(month, monthFont, 100000, sf).Width < ra.Width + 4)
                    {
                        g.DrawString(month, monthFont, brush, ra, sf);
                    }
                    else if (g.MeasureString(UICulture.DateTimeFormat.GetMonthName(startMonth), monthFont, 100000, sf).Width < ra.Width + 4)
                    {
                        g.DrawString(UICulture.DateTimeFormat.GetMonthName(startMonth), monthFont, brush, ra, sf);
                    }

                    cm.Add(new CoordsMap(RowTypes.Months, ra, startMonth));
                    startMonth    = todayDate.Month;
                    firstColMonth = currentPixel;
                }
                if (weekRow != -1 && (todayDate.DayOfWeek == UICulture.DateTimeFormat.FirstDayOfWeek || i == days))
                {
                    ra = new Rectangle(left + firstColWeek, weekRow, currentPixel - firstColWeek, rowsSize);
                    g.DrawRectangle(pen, ra);
                    g.DrawString(startWeek.ToString(), monthFont, brush, ra, sf);
                    cm.Add(new CoordsMap(RowTypes.Weeks, ra, startWeek));
                    startWeek++;
                    firstColWeek = currentPixel;
                }
                if (dayRow != -1 && i != days)
                {
                    ra       = new Rectangle(left + dayLeft, dayRow, dayColumnSize, rowsSize);
                    dayLeft += (dayColumnSize);

                    Rectangle r = ra;
                    r.Height = colHeight;
                    if (todayDate.DayOfWeek == DayOfWeek.Sunday || todayDate.DayOfWeek == DayOfWeek.Saturday)
                    {
                        g.FillRectangle(dayBrush, r);
                    }
                    g.DrawRectangle(pen, r);
                    cm.Add(new CoordsMap(RowTypes.Days, r, i));

                    g.DrawString(cal.GetDayOfMonth(todayDate).ToString(), monthDayFont, brush, ra, sf);
                    Rectangle r2 = ra;
                    r2.Y += monthDayFont.Height;
                    g.DrawString(UICulture.DateTimeFormat.GetShortestDayName(cal.GetDayOfWeek(todayDate)).ToUpper().Substring(0, 1), monthDayFont, brush, r2, sf);
                    if (todayDate.ToShortDateString() == DateTime.Now.ToShortDateString())
                    {
                        g.DrawLine(new Pen(Color.Red), currentPixel, dayRow, currentPixel, dayRow + colHeight);
                    }
                }
            }
            dayRow    += monthDayFont.Height;
            coordsMaps = cm;
            return(img);
        }