Пример #1
0
        /// <summary>
        /// 格式化输出时间
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public string DateTimeFormat(DateTime dt, FormatDate format = FormatDate.Normal)
        {
            var dtfi    = DateTimeFormatInfo.InvariantInfo;
            var _result = string.Empty;

            switch (format.ToString())
            {
            case "ShortDate":
                _result = dt.ToString("d", dtfi);
                break;

            case "FullDate":
                _result = dt.ToString("G", dtfi);
                break;

            case "Date":
                _result = dt.ToString("g", dtfi);
                break;

            case "Normal":
                _result = dt.ToString("u", dtfi);
                _result = _result.Substring(0, _result.Length - 1);
                break;

            case "Time1":
                _result = dt.ToString("t", dtfi);
                break;

            case "Time":
            default:
                _result = dt.ToString("T", dtfi);
                break;
            }
            return(_result);
        }
Пример #2
0
        public void TestSimpleFormatOfString()
        {
            var date = new FormatDate();

            date.Value = new MockAttribute(new Constant("1/6/2008 12:00:00"));
            Assert.That(date.Evaluate(_model), Is.EqualTo("01/06/2008 12:00"));
        }
Пример #3
0
        public void CheckRequired()
        {
            var tag = new FormatDate();

            RequiredAttribute.Check(tag);
            //no exceptions
        }
Пример #4
0
        public override Task SetParametersAsync(ParameterView parameters)
        {
            _oldIsDatePickerShown = IsDatePickerShown;

            DateTime nextMinDate, nextMaxDate, nextInitialPickerDate;
            DateTime?nextValue;
            bool     nextIsRequired;
            Func <DateTime, string> nextFormatDate;

            if (!parameters.TryGetValue("MinDate", out nextMinDate))
            {
                nextMinDate = MinDate;
            }
            if (!parameters.TryGetValue("MaxDate", out nextMaxDate))
            {
                nextMaxDate = MaxDate;
            }
            if (!parameters.TryGetValue("Value", out nextValue))
            {
                nextValue = Value;
            }
            if (!parameters.TryGetValue("InitialPickerDate", out nextInitialPickerDate))
            {
                nextInitialPickerDate = InitialPickerDate;
            }
            if (!parameters.TryGetValue("IsRequired", out nextIsRequired))
            {
                nextIsRequired = IsRequired;
            }
            if (!parameters.TryGetValue("FormatDate", out nextFormatDate))
            {
                nextFormatDate = FormatDate;
            }

            if (DateTime.Compare(MinDate, nextMinDate) == 0 &&
                DateTime.Compare(MaxDate, nextMaxDate) == 0 &&
                IsRequired == nextIsRequired &&
                DateTimeCompareNullable(SelectedDate, nextValue) == 0 &&
                FormatDate != null &&
                (FormatDate.Equals(nextFormatDate) || nextFormatDate == null))  //since FormatDate may not be set as a parameter, it's ok for nextFormatDate to be null
            {
                return(base.SetParametersAsync(parameters));
            }

            this.SetErrorMessage(true, nextIsRequired, nextValue, nextMinDate, nextMaxDate, nextInitialPickerDate);

            var oldValue = SelectedDate;

            if (DateTimeCompareNullable(oldValue, nextValue) != 0 ||
                (FormatDate != null &&
                 nextFormatDate != null &&
                 ((nextValue != null? FormatDate((DateTime)nextValue): null) != (nextValue != null? nextFormatDate((DateTime)nextValue): null))))
            {
                SelectedDate  = nextValue;
                FormattedDate = FormatDateInternal(nextValue);
            }

            return(base.SetParametersAsync(parameters));
        }
Пример #5
0
        public void TestSimpleFormatOfDateTime()
        {
            var date = new FormatDate();

            _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6);
            date.Value = new MockAttribute(new Property("DateValue"));
            Assert.That(date.Evaluate(_model), Is.EqualTo("02/03/2001 04:05"));
        }
Пример #6
0
        public void TestSimpleFormatOfEmptyString()
        {
            var date = new FormatDate();

            date.Value = new MockAttribute(new Constant(""));

            Assert.That(date.Evaluate(_model), Is.EqualTo(String.Empty));
        }
Пример #7
0
 private void PurchaseHistoryReportToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SFD.Filter   = "PDF файл|*.pdf";
     SFD.Title    = "Сохранить отчет по продажам";
     SFD.FileName = "Отчет по продажам на " + FormatDate.GetNowDate();
     SavingFile   = "PurchaseHistoryReport";
     SFD.ShowDialog();
 }
Пример #8
0
 private void ShipmentReportToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SFD.Filter   = "PDF файл|*.pdf";
     SFD.Title    = "Сохранить отчет по товарам";
     SFD.FileName = "Отчет по товарам на " + FormatDate.GetNowDate();
     SavingFile   = "ShipmentReport";
     SFD.ShowDialog();
 }
Пример #9
0
 private void CreateBackupToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SFD.Filter   = "XML файл|*.xml";
     SFD.Title    = "Сохранить резервную копию";
     SFD.FileName = "Backup" + FormatDate.GetNowDate();
     SavingFile   = "Backup";
     SFD.ShowDialog();
 }
Пример #10
0
        public void TestSimpleFormatOfWithCustomPatternWithTimeZone()
        {
            var date = new FormatDate();

            _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6);
            date.Value   = new MockAttribute(new Property("DateValue"));
            date.Pattern = new MockAttribute(new Constant("HH:mm zzz"));
            Assert.That(date.Evaluate(_model), Is.EqualTo("04:05 +01:00"));
        }
Пример #11
0
        public void TestSimpleFormatOfWithCustomPattern()
        {
            var date = new FormatDate();

            _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6);
            date.Value   = new MockAttribute(new Property("DateValue"));
            date.Pattern = new MockAttribute(new Constant("dd MMM yyyy'T'HH:mm"));
            Assert.That(date.Evaluate(_model), Is.EqualTo("03 Feb 2001T04:05"));
        }
Пример #12
0
        public void TestSimpleFormatOfDateTimeOnlyTime()
        {
            var date = new FormatDate();

            _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6);
            date.Value = new MockAttribute(new Property("DateValue"));
            date.Type  = new MockAttribute(new Constant(DateType.Time.ToString()));
            Assert.That(date.Evaluate(_model), Is.EqualTo("04:05"));
        }
Пример #13
0
        public void TestSimpleFormatOfWithBothLongFormat()
        {
            var date = new FormatDate();

            _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6);
            date.Value     = new MockAttribute(new Property("DateValue"));
            date.TimeStyle = new MockAttribute(new Constant(TimeStyle.Long.ToString()));
            date.DateStyle = new MockAttribute(new Constant(DateStyle.Long.ToString()));
            Assert.That(date.Evaluate(_model), Is.EqualTo("Saturday, 03 February 2001 04:05:06"));
        }
Пример #14
0
        public void TestSimpleFormatOfDifferentDateStyle_Short()
        {
            var date = new FormatDate();

            _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6);
            date.Value     = new MockAttribute(new Property("DateValue"));
            date.Type      = new MockAttribute(new Constant(DateType.Date.ToString()));
            date.DateStyle = new MockAttribute(new Constant(DateStyle.Short.ToString()));
            Assert.That(date.Evaluate(_model), Is.EqualTo("02/03/2001"));
        }
Пример #15
0
        public void TestSimpleFormatOfDifferentTimeStyle_ShortDifferentCulture()
        {
            var date = new FormatDate();

            _model.Model["DateValue"]           = new DateTime(2001, 2, 3, 14, 5, 6);
            _model.Page[FormatConstants.LOCALE] = new CultureInfo("nl-NL");
            date.Value     = new MockAttribute(new Property("DateValue"));
            date.Type      = new MockAttribute(new Constant(DateType.Time.ToString()));
            date.TimeStyle = new MockAttribute(new Constant(TimeStyle.Short.ToString()));
            Assert.That(date.Evaluate(_model), Is.EqualTo("14:05"));
        }
Пример #16
0
        public void TestSimpleFormatOfWithBothLongFormatPatternOverride()
        {
            var date = new FormatDate();

            _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6);
            date.Value     = new MockAttribute(new Property("DateValue"));
            date.TimeStyle = new MockAttribute(new Constant(TimeStyle.Long.ToString()));
            date.DateStyle = new MockAttribute(new Constant(DateStyle.Long.ToString()));
            date.Pattern   = new MockAttribute(new Constant("dd MMM yyyy'T'HH:mm"));
            Assert.That(date.Evaluate(_model), Is.EqualTo("03 Feb 2001T04:05"));
        }
Пример #17
0
 protected void btnListar_Click(object sender, EventArgs e)
 {
     if (txbDOB.Text.Equals(""))
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Pop", "modalAguarde();", true);
     }
     else
     {
         Response.Redirect("~/administrativo/ListaInternados.aspx?data_carga=" + FormatDate.formatarData(txbDOB.Text));
     }
 }
Пример #18
0
        private void OnSubmitExcuted()
        {
            FormatDate fd = new FormatDate();

            if (CBFBM != null & CBFLX != null & CBFDB != null & CardType != null & CardID != null & Address != null & PostCode != null & Tel != null & FamilyCount != null & CBFDCRQ != null & CBFDCY != null & CBFDCJS != null & GSJS != null & GSJSR != null & GSSHRQ != null & GSSHR != null)
            {
                CBFModels _CBF = new CBFModels();
                _CBF.ID         = CBFBM;
                _CBF.Name       = CBFDB;
                _CBF.CardNumber = CardID;
                _CBF.Address    = Address;
                // _CBF.CertificateType = CBFLX;
                _CBF.Claimsman         = CBFDCY;
                _CBF.MemberCount       = FamilyCount;
                _CBF.PublicEvent       = GSJS;
                _CBF.PublicEventPerson = GSJSR;
                _CBF.SurveyDate        = fd.GetFormatedDate(CBFDCRQ);
                _CBF.SurveyEvent       = CBFDCJS;
                _CBF.PublicCheckPerson = GSSHR;
                _CBF.Tel        = Tel;
                _CBF.PublicDate = fd.GetFormatedDate(GSSHRQ);
                _CBF.PostCode   = PostCode;
                _CBF.Family     = FamilyCollection;

                CBFDatabaseServices db = new CBFDatabaseServices();
                db.CreateCBF(_CBF);
                CBFBM            = null;
                CBFDB            = null;
                CardID           = null;
                Address          = null;
                CBFDCY           = null;
                FamilyCount      = null;
                GSJS             = null;
                GSJSR            = null;
                CBFDCRQ          = null;
                CBFDCJS          = null;
                GSSHR            = null;
                Tel              = null;
                GSSHRQ           = null;
                PostCode         = null;
                FamilyCollection = null;
            }
            else
            {
                MessageBox.Show("表单数据未填写完整或格式不正确,请检查后再试");
            }
        }
Пример #19
0
        public void TestSimpleFormatOfDifferentDateStyle_Wrong()
        {
            var date = new FormatDate();

            _model.Model["DateValue"] = new DateTime(2001, 2, 3, 4, 5, 6);
            date.Value     = new MockAttribute(new Property("DateValue"));
            date.Type      = new MockAttribute(new Constant(DateType.Date.ToString()));
            date.DateStyle = new MockAttribute(new Constant("Wrong"));
            try
            {
                date.Evaluate(_model);
                Assert.Fail("Expected failure");
            }
            catch (ArgumentException Ae)
            {
                Assert.That(Ae.Message.Contains("Wrong"));
            }
        }
Пример #20
0
    public static List <Paciente> getListaPacientesInternadosUltimaCarga(string data_carga)
    {
        string data = data_carga;
        int    dia  = Convert.ToInt32(data.Substring(0, 2));
        int    mes  = Convert.ToInt32(data.Substring(3, 2));
        int    ano  = Convert.ToInt32(data.Substring(6, 4));

        //int dia = DateTime.Now.Day;
        //int mes = DateTime.Now.Month;
        //int ano = DateTime.Now.Year;



        var listaInternados = new List <Paciente>();

        using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["nirConnectionString"].ToString()))
        {
            SqlCommand cmm         = cnn.CreateCommand();
            string     sqlConsulta = "SELECT [prontuario]" +
                                     ",[nome]" +
                                     ",[quarto]" +
                                     ",[unidade_funcional]" +
                                     ",[dt_internacao]" +
                                     ",[especialidade]" +
                                     ",[tempo]" +
                                     ",[cid]" +
                                     ",[descricao_cid]" +
                                     ",[diagnostico]" +
                                     ",[detalhamento]" +
                                     ",[aguarda]" +
                                     ",[cod_internacao]" +
                                     ",[data_carga]" +
                                     ",[nascimento]" +
                                     " FROM [v_relatorio_detalhado] " +
                                     " WHERE DAY(data_carga) = " + dia + " and MONTH(data_carga)= " + mes + " and YEAR(data_carga)= " + ano;
            cmm.CommandText = sqlConsulta;
            try
            {
                cnn.Open();
                SqlDataReader dr1 = cmm.ExecuteReader();
                while (dr1.Read())
                {
                    Paciente p = new Paciente();

                    p.prontuario           = dr1.GetInt32(0);
                    p.nome                 = dr1.GetString(1);
                    p.quarto               = dr1.GetInt32(2);
                    p.unidade_funcional    = dr1.GetString(3);
                    p.data_internacao_data = dr1.GetString(4);
                    p.especialidade        = dr1.GetString(5);
                    p.tempo                = dr1.GetString(6);
                    p.cid           = dr1.GetString(7);
                    p.descricao_cid = dr1.GetString(8);
                    //colocar o cid no diagnóstico. Em 09/04/2021
                    p.diagnostico    = p.cid.ToString() + " - " + p.descricao_cid;
                    p.diagnostico   += dr1.IsDBNull(9) ? "" : ";" + dr1.GetString(9);
                    p.detalhamento   = dr1.IsDBNull(10) ? "" : dr1.GetString(10);
                    p.aguarda        = dr1.IsDBNull(11) ? "" : dr1.GetString(11);
                    p.cod_internacao = dr1.GetInt32(12);
                    p.data_carga     = dr1.GetDateTime(13);
                    p.nascimento     = dr1.GetString(14);
                    p.idade          = FormatDate.CalculaIdade(p.nascimento);
                    listaInternados.Add(p);
                }
            }
            catch (Exception ex)
            {
                string error = ex.Message;
            }
            //listaInternados.OrderBy(internado => internado.quarto);

            return(listaInternados);
        }
    }
Пример #21
0
        public static bool PurchaseHistoryReport(string file, ShipmentList Shipments, PurchaseHistoryList PurHisList)
        {
            List <string> Dates  = new List <string>();
            List <int>    Counts = new List <int>();
            List <int>    Costs  = new List <int>();

            for (int i = 0; i < PurHisList.Count; i++)
            {
                if (Dates.Count == 0)
                {
                    Dates.Add(FormatDate.GetDate(PurHisList[i].Day, PurHisList[i].Month, PurHisList[i].Year));
                    Counts.Add(PurHisList[i].Count);
                    foreach (Shipment SH in Shipments.Shipments)
                    {
                        if (SH.ShipmentID == PurHisList[i].ShipmentID)
                        {
                            Costs.Add(PurHisList[i].Count * SH.Price);
                            break;
                        }
                    }
                }
                else
                {
                    int numberOfDate = -1;
                    for (int j = 0; j < Dates.Count; j++)
                    {
                        if (FormatDate.GetDate(PurHisList[i].Day, PurHisList[i].Month, PurHisList[i].Year) == Dates[j])
                        {
                            numberOfDate = j;
                            break;
                        }
                    }
                    if (numberOfDate != -1)
                    {
                        Counts[numberOfDate] += PurHisList[i].Count;
                        foreach (Shipment SH in Shipments.Shipments)
                        {
                            if (SH.ShipmentID == PurHisList[i].ShipmentID)
                            {
                                Costs[numberOfDate] += PurHisList[i].Count * SH.Price;
                                break;
                            }
                        }
                    }
                    else
                    {
                        Dates.Add(FormatDate.GetDate(PurHisList[i].Day, PurHisList[i].Month, PurHisList[i].Year));
                        Counts.Add(PurHisList[i].Count);
                        foreach (Shipment SH in Shipments.Shipments)
                        {
                            if (SH.ShipmentID == PurHisList[i].ShipmentID)
                            {
                                Costs.Add(PurHisList[i].Count * SH.Price);
                                break;
                            }
                        }
                    }
                }
            }

            PDF.CreatePurchaseHistoryReport(file, Dates, Counts, Costs);
            return(true);
        }
Пример #22
0
    protected void btnVoltarLista_Click(object sender, EventArgs e)
    {
        string data = lbdtCarga.Text;

        Response.Redirect("~/administrativo/ListaInternados.aspx?data_carga=" + FormatDate.formatarData(data));
    }
Пример #23
0
        public static void CreatePurchaseHistoryReport(string file, List <string> Dates, List <int> Counts, List <int> Costs)
        {
            var       doc    = new Document();
            PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(file, FileMode.Create));

            string   fg         = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "Tahoma.TTF");
            BaseFont fgBaseFont = BaseFont.CreateFont(fg, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            Font     Font       = new Font(fgBaseFont, 12, Font.BOLD, BaseColor.BLACK);
            Font     mainFont   = new Font(fgBaseFont, 10, Font.NORMAL, BaseColor.BLACK);

            doc.Open();

            Paragraph p   = new Paragraph();
            Phrase    phr = new Phrase("Отчет по продажам за " + FormatDate.GetNowDate(), Font);

            p.Alignment = 1;
            p.Add(phr);
            doc.Add(p);

            p           = new Paragraph();
            phr         = new Phrase(" ", Font);
            p.Alignment = 1;
            p.Add(phr);
            doc.Add(p);

            PdfPTable Table = new PdfPTable(6);

            PdfPCell cell = new PdfPCell(new Phrase("№", mainFont));

            cell.BorderWidth = 1;
            Table.AddCell(cell);

            cell             = new PdfPCell(new Phrase("Дата продаж", mainFont));
            cell.BorderWidth = 1;
            cell.Colspan     = 3;
            Table.AddCell(cell);

            cell             = new PdfPCell(new Phrase("Суммарное количество купленного товара", mainFont));
            cell.BorderWidth = 1;
            Table.AddCell(cell);

            cell             = new PdfPCell(new Phrase("Сумма всех покупок", mainFont));
            cell.BorderWidth = 1;
            Table.AddCell(cell);

            for (int i = 0; i < Dates.Count; i++)
            {
                cell             = new PdfPCell(new Phrase((i + 1).ToString(), mainFont));
                cell.BorderWidth = 1;
                Table.AddCell(cell);

                cell             = new PdfPCell(new Phrase(Dates[i], mainFont));
                cell.BorderWidth = 1;
                cell.Colspan     = 3;
                Table.AddCell(cell);

                cell             = new PdfPCell(new Phrase(Counts[i].ToString(), mainFont));
                cell.BorderWidth = 1;
                Table.AddCell(cell);

                cell             = new PdfPCell(new Phrase(Costs[i].ToString(), mainFont));
                cell.BorderWidth = 1;
                Table.AddCell(cell);
            }

            doc.Add(Table);

            p           = new Paragraph();
            phr         = new Phrase(" ", Font);
            p.Alignment = 1;
            p.Add(phr);
            doc.Add(p);

            p           = new Paragraph();
            phr         = new Phrase("Подпись   _______________", Font);
            p.Alignment = 2;
            p.Add(phr);
            doc.Add(p);

            doc.Close();
            writer.Close();
        }
Пример #24
0
        public void TestEmpty()
        {
            var date = new FormatDate();

            Assert.That(date.Evaluate(_model), Is.EqualTo(String.Empty));
        }