Exemple #1
0
        //根据PrintInCommonView进行判断调用哪个打印模板
        public void LoadPrint(PrintInCommonView printInCommonView)
        {
            try
            {
                m_printInCommonView = printInCommonView;

                PrintInCommonView printInCommonViewClone = AddLineCount();

                XDesigner.Report.DataBaseReportBuilder builder = new XDesigner.Report.DataBaseReportBuilder();
                builder.SetVariable("PrintInCommonView", new object[] { printInCommonViewClone });
                string path = Application.StartupPath.ToString();
                path += @"\Report\" + printInCommonViewClone.PrintFileName + ".xrp";
                if (path == null)
                {
                    return;
                }
                bool hasfile = File.Exists(path);
                if (hasfile)
                {
                    builder.Load(path);
                    builder.Refresh();
                    xPrint.Document = builder.ReportDocument;
                    xPrint.RefreshView();
                }
                else
                {
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("打印模板文件不存在");
                }
            }
            catch (Exception ex)
            {
                DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(ex.StackTrace);
            }
        }
Exemple #2
0
        /// <summary>
        /// 装换对象RecordPrintView
        /// </summary>
        /// <param name="printInCommonView"></param>
        /// <returns></returns>
        RecordPrintView ConvertPrintView(PrintInCommonView printInCommonView)
        {
            RecordPrintView recordPrintView = new RecordPrintView();
            string          fileName        = AppDomain.CurrentDomain.BaseDirectory + @"Report\" + printInCommonView.PrintFileName + ".xml";

            recordPrintView.PrintFileName        = fileName;
            recordPrintView.RecordName           = printInCommonView.RecordName;
            recordPrintView.PrintInpatientView   = printInCommonView.PrintInpatientView;
            recordPrintView.PrintInCommonTabView = printInCommonView.PrintInCommonTabViewList1;
            if (printInCommonView.PrintInCommonTabViewList2 != null &&
                printInCommonView.PrintInCommonTabViewList2.PrintInCommonItemViewList != null &&
                printInCommonView.PrintInCommonTabViewList2.PrintInCommonItemViewList.Count > 0)
            {
                recordPrintView.PrintInCommonItemViewOther = printInCommonView.PrintInCommonTabViewList2.PrintInCommonItemViewList[0];
            }
            if (recordPrintView.PrintInCommonItemViewList == null)
            {
                recordPrintView.PrintInCommonItemViewList = new List <PrintInCommonItemView>();
            }
            if (recordPrintView.PrintInCommonItemViewOther == null)
            {
                recordPrintView.PrintInCommonItemViewOther = new PrintInCommonItemView();
            }

            return(recordPrintView);
        }
Exemple #3
0
        /// <summary>
        /// 将一列变成可绑定的多列  最大只有5大列
        /// </summary>
        /// <param name="printInCommonView"></param>
        private void ConvertForDuoLie(PrintInCommonView printInCommonView)
        {
            List <PrintInCommonItemView> printInCommonItemViewListOld = printInCommonView.PrintInCommonTabViewList1.PrintInCommonItemViewList;

            if (printInCommonItemViewListOld == null)
            {
                return;
            }
            Dictionary <string, string> dicstr = InCommonNoteBiz.GetReportxmlCol(printInCommonView);

            if (!dicstr.ContainsKey("maxCols"))
            {
                return;
            }
            string maxcols = dicstr["maxCols"]; //大列数
            int    maxcolsint;                  //大列
            bool   ismax = int.TryParse(maxcols, out maxcolsint);

            if (maxcolsint <= 1 || maxcolsint > 5)
            {
                return;
            }
            List <PrintInCommonItemView> printInCommonItemViewListNew = new List <PrintInCommonItemView>();

            for (int i = 0; i < printInCommonItemViewListOld.Count; i++)
            {
                int yushu = i % maxcolsint;
                if (yushu == 0)
                {
                    PrintInCommonItemView printInCommonItemView = new PrintInCommonItemView();
                    if (maxcolsint >= 5 &&
                        (i + 4 < printInCommonItemViewListOld.Count))
                    {
                        printInCommonItemView.PrintInCommonItemView5 = printInCommonItemViewListOld[i + 4];
                    }
                    if (maxcolsint >= 4 &&
                        (i + 3 < printInCommonItemViewListOld.Count))
                    {
                        printInCommonItemView.PrintInCommonItemView4 = printInCommonItemViewListOld[i + 3];
                    }
                    if (maxcolsint >= 3 &&
                        (i + 2 < printInCommonItemViewListOld.Count))
                    {
                        printInCommonItemView.PrintInCommonItemView3 = printInCommonItemViewListOld[i + 2];
                    }
                    if (maxcolsint >= 2 &&
                        (i + 1 < printInCommonItemViewListOld.Count))
                    {
                        printInCommonItemView.PrintInCommonItemView2 = printInCommonItemViewListOld[i + 1];
                    }
                    printInCommonItemView.PrintInCommonItemView1 = printInCommonItemViewListOld[i];

                    printInCommonItemViewListNew.Add(printInCommonItemView);  //添加整理好的一行
                }
            }

            printInCommonView.PrintInCommonTabViewList1.PrintInCommonItemViewList = printInCommonItemViewListNew;
        }
Exemple #4
0
 public PrintForm1(PrintInCommonView printInCommonView)
 {
     try
     {
         //<PrintPageSize width="1654" height="1169" type="A3"></PrintPageSize>
         InitializeComponent();
         InitPrintView(printInCommonView);
         speNum.Value = GetSpitValue();
     }
     catch (Exception ex)
     {
         DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(ex.Message + ex.StackTrace);
     }
 }
Exemple #5
0
        /// <summary>
        /// 初始化数据
        /// </summary>
        /// <param name="printInCommonView"></param>
        private void InitPrintView(PrintInCommonView printInCommonView)
        {
            printPageNowPer           = 0;
            m_printInCommonView       = printInCommonView;
            printPreviewControl1.Rows = 1;
            iPrintNurse = AbstractorFactry.GetNurseRecord(printInCommonView.PrintFileName);
            string      fileName = AppDomain.CurrentDomain.BaseDirectory + @"Report\" + printInCommonView.PrintFileName + ".xml";
            XmlDocument xmldoc   = new XmlDocument();

            xmldoc.Load(fileName);
            iPrintNurse.PageRecordCount = int.Parse(CommonMethods.GetElementAttribute("ImageSize", "rowCount", xmldoc));
            string PaperType = CommonMethods.GetElementAttribute("PrintPageSize", "type", xmldoc);
            int    width;
            int    heigth;

            int.TryParse(CommonMethods.GetElementAttribute("PrintPageSize", "width", xmldoc), out width);
            int.TryParse(CommonMethods.GetElementAttribute("PrintPageSize", "height", xmldoc), out heigth);
            Landscape = CommonMethods.GetElementAttribute("PrintPageSize", "Landscape", xmldoc).ToUpper() == "TRUE" ? true : false;

            PrintDocument printDocumentPre = new PrintDocument();
            PrintDialog   MySettings       = new PrintDialog();

            MySettings.Document = printDocumentPre;

            foreach (PaperSize ps in MySettings.Document.PrinterSettings.PaperSizes)
            {
                if (ps.Kind.ToString().ToUpper().Equals(PaperType.ToUpper()))//这里设置纸张大小,但必须是定义好的
                {
                    paperSize = ps;
                    break;
                }
            }
            if (paperSize == null)
            {
                paperSize           = new PaperSize();
                paperSize.PaperName = PaperType;
                paperSize.Width     = width;
                paperSize.Height    = heigth;
            }
            MySettings.Document.DefaultPageSettings.PaperSize = paperSize;
            MySettings.Document.DefaultPageSettings.Landscape = Landscape;

            //printDocumentPre.DefaultPageSettings.PaperSize = paperSize;

            int PageRecordCount           = iPrintNurse.PageRecordCount; //每张的行数
            var PrintInCommonItemViewList = m_printInCommonView.PrintInCommonTabViewList1.PrintInCommonItemViewList;

            if (PrintInCommonItemViewList == null)
            {
                PrintInCommonItemViewList = new List <PrintInCommonItemView>();
            }
            int allcount  = PrintInCommonItemViewList.Count;
            int pageCount = (allcount + PageRecordCount - 1) / PageRecordCount;  //总页数

            if (pageCount == 0)
            {
                pageCount = 1;
            }
            printEnd = pageCount;

            printDocumentPre.PrintPage   += new PrintPageEventHandler(printDocumentPre_PrintPage);
            printPreviewControl1.Document = printDocumentPre;
            printPreviewControl1.Zoom     = 1;
        }
Exemple #6
0
        public void ConverToDuoRow(PrintInCommonView printInCommonView)
        {
            try
            {
                List <PrintInCommonItemView> printInCommonItemViewListOld = printInCommonView.PrintInCommonTabViewList1.PrintInCommonItemViewList;
                if (printInCommonItemViewListOld == null)
                {
                    return;
                }
                Dictionary <string, ColmonXMLEntity> dicwordcounts = InCommonNoteBiz.GetReportxmlwords(printInCommonView);  //xml中属性 和最大字符数
                if (dicwordcounts == null || dicwordcounts.Count == 0)
                {
                    return;
                }
                List <PrintInCommonItemView> printInCommonItemViewListOut = new List <PrintInCommonItemView>(); //存放处理好的对象
                List <PrintInCommonItemView> printInCommonItemViewListNew = new List <PrintInCommonItemView>();

                Dictionary <string, List <PrintInCommonItemView> > dicIncommList = new Dictionary <string, List <PrintInCommonItemView> >();

                //将datetime时间相同的分组
                for (int i = 0; i < printInCommonItemViewListOld.Count; i++)
                {
                    if (!dicIncommList.ContainsKey(printInCommonItemViewListOld[i].DateTimeShow))
                    {
                        dicIncommList.Add(printInCommonItemViewListOld[i].DateTimeShow, new List <PrintInCommonItemView>());
                    }
                    dicIncommList[printInCommonItemViewListOld[i].DateTimeShow].Add(printInCommonItemViewListOld[i]);
                }


                foreach (List <PrintInCommonItemView> incommItemList in dicIncommList.Values)
                {
                    #region 处理数据
                    printInCommonItemViewListNew = incommItemList;
                    int maxrow = -1;                                                             //用于获取一个对象中被分成的最大行数
                    Dictionary <string, string> dicNeedRows = new Dictionary <string, string>(); //需要换行的列 值
                    foreach (var item in dicwordcounts)
                    {
                        string valueStr = "";
                        if (item.Value == null)
                        {
                            break;
                        }
                        string proName = item.Key;  //属性名

                        foreach (var inCommonItem in printInCommonItemViewListNew)
                        {
                            PropertyInfo property = inCommonItem.GetType().GetProperty(proName); //获取该对象的该属性
                            if (property != null)
                            {
                                object valueobj = property.GetValue(inCommonItem, null);
                                if (valueobj != null)
                                {
                                    valueStr += valueobj.ToString();
                                }
                                property.SetValue(inCommonItem, "", null);
                            }
                        }
                        //xll 20130228 伤处字符中的/r 回车键
                        //valueStr = valueStr.Replace("\n", "");

                        dicNeedRows.Add(proName, valueStr);
                        int zheshu = GetNeedRows(valueStr, item.Value).Count;
                        if (zheshu > maxrow)
                        {
                            maxrow = zheshu;
                        }
                    }   //获得需要换行的属性和值的集合 并获得需要的最大行数


                    //处理数据 最终的分行处理
                    for (int j = 0; j < maxrow; j++)
                    {
                        foreach (var itemneed in dicNeedRows)  //对各列进行截取
                        {
                            string proName = itemneed.Key;
                            if (j >= printInCommonItemViewListNew.Count)
                            {
                                PrintInCommonItemView printInCommonItemView = new CommonNoteUse.PrintInCommonItemView();
                                printInCommonItemView.Date                = printInCommonItemViewListNew[0].Date;
                                printInCommonItemView.Time                = printInCommonItemViewListNew[0].Time;
                                printInCommonItemView.DateTimeShow        = printInCommonItemViewListNew[0].DateTimeShow;
                                printInCommonItemView.RecordDoctorId      = printInCommonItemViewListNew[0].RecordDoctorId;
                                printInCommonItemView.RecordDoctorName    = printInCommonItemViewListNew[0].RecordDoctorName;
                                printInCommonItemView.RecordDoctorImg     = printInCommonItemViewListNew[0].RecordDoctorImg;
                                printInCommonItemView.RecordDoctorImgbyte = printInCommonItemViewListNew[0].RecordDoctorImgbyte;
                                printInCommonItemViewListNew.Add(printInCommonItemView);
                            }

                            PropertyInfo property      = printInCommonItemViewListNew[j].GetType().GetProperty(proName); //获取该对象的该属性
                            string       rowindexvalue = GetIndexStr(j, GetNeedRows(itemneed.Value, dicwordcounts[proName]));
                            property.SetValue(printInCommonItemViewListNew[j], rowindexvalue, null);
                        }
                    }
                    #endregion
                    //将处理好的对象集合存放到最新的数据集中
                    printInCommonItemViewListOut.AddRange(printInCommonItemViewListNew);
                }
                printInCommonView.PrintInCommonTabViewList1.PrintInCommonItemViewList = printInCommonItemViewListOut;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #7
0
        /// <summary>
        /// 打印表格时一行不过换行显示
        /// </summary>
        /// <param name="printInCommonView"></param>
        private void ConvertForChangeRow(PrintInCommonView printInCommonView)
        {
            List <PrintInCommonItemView> printInCommonItemViewListOld = printInCommonView.PrintInCommonTabViewList1.PrintInCommonItemViewList;

            if (printInCommonItemViewListOld == null)
            {
                return;
            }
            List <PrintInCommonItemView>         printInCommonItemViewListNew = new List <PrintInCommonItemView>();
            Dictionary <string, ColmonXMLEntity> dicwordcounts = InCommonNoteBiz.GetReportxmlwords(printInCommonView);  //xml中属性 和最大字符数

            if (dicwordcounts == null || dicwordcounts.Count == 0)
            {
                return;
            }
            foreach (var inCommonItem in printInCommonItemViewListOld)
            {
                int maxrow = -1;                                                             //用于获取一个对象中被分成的最大行数
                Dictionary <string, string> dicNeedRows = new Dictionary <string, string>(); //需要换行的列 值
                foreach (var item in dicwordcounts)
                {
                    if (item.Value == null)
                    {
                        break;
                    }
                    string       proName  = item.Key;                                    //属性名
                    PropertyInfo property = inCommonItem.GetType().GetProperty(proName); //获取该对象的该属性
                    if (property != null)
                    {
                        string valuestr = "";
                        object valueobj = property.GetValue(inCommonItem, null);
                        if (valueobj != null)
                        {
                            valuestr = valueobj.ToString();
                        }
                        dicNeedRows.Add(proName, valuestr);
                        int zheshu = GetNeedRows(valuestr, item.Value).Count;
                        if (zheshu > maxrow)
                        {
                            maxrow = zheshu;
                        }
                    }
                }
                if (maxrow == -1)
                {
                    continue;
                }
                if (maxrow == 1 || maxrow == 0)
                {
                    PrintInCommonItemView printInCommonItemView = inCommonItem;
                    printInCommonItemViewListNew.Add(printInCommonItemView);
                }
                else
                {
                    List <PrintInCommonItemView> printInCommonItemOnemore = new List <PrintInCommonItemView>();  //一个正常行最终变成的多行
                    for (int i = 0; i < maxrow; i++)
                    {
                        PrintInCommonItemView printInCommonItemView;
                        if (i == 0)
                        {
                            printInCommonItemView = inCommonItem;
                        }
                        else
                        {
                            printInCommonItemView = new PrintInCommonItemView();
                        }
                        foreach (var itemneed in dicNeedRows)  //对各列进行截取
                        {
                            string       proName       = itemneed.Key;
                            PropertyInfo property      = printInCommonItemView.GetType().GetProperty(proName); //获取该对象的该属性
                            string       rowindexvalue = GetIndexStr(i, GetNeedRows(itemneed.Value, dicwordcounts[proName]));
                            property.SetValue(printInCommonItemView, rowindexvalue, null);
                        }
                        printInCommonItemOnemore.Add(printInCommonItemView);
                    }
                    printInCommonItemOnemore[printInCommonItemOnemore.Count - 1].RecordDoctorName = printInCommonItemOnemore[0].RecordDoctorName;
                    printInCommonItemOnemore[printInCommonItemOnemore.Count - 1].RecordDoctorId   = printInCommonItemOnemore[0].RecordDoctorId;
                    printInCommonItemOnemore[printInCommonItemOnemore.Count - 1].RecordDoctorImg  = printInCommonItemOnemore[0].RecordDoctorImg;
                    printInCommonItemOnemore[0].RecordDoctorName = "";
                    printInCommonItemOnemore[0].RecordDoctorId   = "";
                    printInCommonItemOnemore[0].RecordDoctorImg  = "";
                    printInCommonItemViewListNew.AddRange(printInCommonItemOnemore);
                }
            }
            printInCommonView.PrintInCommonTabViewList1.PrintInCommonItemViewList = printInCommonItemViewListNew;
        }
Exemple #8
0
        /// <summary>
        /// 切换tab触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tabcontrol_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
        {
            if (tabcontrol.SelectedTabPage != tabPagePrint)
            {
                return;
            }
            WaitDialogForm waitDialog = new WaitDialogForm("正在组织打印数据……", "请稍等。");

            try
            {
                //xll 2013-03-26 获取全部数据 点击全部了 就无需再次查找 点击其他的 需要查找
                foreach (XtraTabPage item in tabcontrol.TabPages)
                {
                    if (item.Controls.Count > 0)
                    {
                        UCIncommonNoteTab uCIncommonNoteTab = item.Controls[0] as UCIncommonNoteTab;
                        if (uCIncommonNoteTab != null)
                        {
                            m_inCommonNote = uCIncommonNoteTab.GetAllDetailDate();
                            break;
                        }
                    }
                }
                PrintInCommonView printInCommonView = ConvertPrintEntity();

                iPrintNurse = AbstractorFactry.GetNurseRecord(printInCommonView.PrintFileName);
                SetWaitDialogCaption("正在绘制预览界面……", waitDialog);
                if (iPrintNurse != null && iPrintNurse.IsCustomPrint == true)
                {
                    if (tabPagePrint.Controls == null || tabPagePrint.Controls.Count <= 0)
                    {
                        PrintForm1 printForm1 = new PrintForm1(printInCommonView);
                        printForm1.Dock            = DockStyle.Fill;
                        printForm1.TopLevel        = false;
                        printForm1.FormBorderStyle = FormBorderStyle.None;
                        printForm1.Show();
                        tabPagePrint.Controls.Add(printForm1);
                    }
                    else
                    {
                        PrintForm1 printForm1 = tabPagePrint.Controls[0] as PrintForm1;
                        if (printForm1 != null)
                        {
                            printForm1.m_printInCommonView = printInCommonView;
                            printForm1.RefreshView();
                        }
                    }
                }
                else
                {
                    if (ucPrintRecord == null)
                    {
                        ucPrintRecord = new UCPrintRecord();
                        tabPagePrint.Controls.Add(ucPrintRecord);
                        ucPrintRecord.Dock = DockStyle.Fill;
                    }
                    ucPrintRecord.LoadPrint(printInCommonView);
                }
                waitDialog.Hide();
                waitDialog.Close();
            }
            catch (Exception ex)
            {
                waitDialog.Hide();
                waitDialog.Close();
                DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(1, ex);
            }
        }
Exemple #9
0
        /// <summary>
        /// 从界面获取空行添加
        /// </summary>
        private PrintInCommonView AddLineCount()
        {
            //复制一个一样的对象
            PrintInCommonView printInCommonViewClone = CommonTabHelper.Clone <PrintInCommonView>(m_printInCommonView);
            int linecount = Convert.ToInt32(spinEditLineCount.Value);

            if (linecount > 0)
            {
                if (printInCommonViewClone.PrintInCommonTabViewList1 == null)
                {
                    printInCommonViewClone.PrintInCommonTabViewList1 = new PrintInCommonTabView();
                }
                if (printInCommonViewClone.PrintInCommonTabViewList1.PrintInCommonItemViewList == null)
                {
                    printInCommonViewClone.PrintInCommonTabViewList1.PrintInCommonItemViewList = new List <PrintInCommonItemView>();
                }
                for (int i = 0; i < linecount; i++)
                {
                    printInCommonViewClone.PrintInCommonTabViewList1.PrintInCommonItemViewList.Add(new PrintInCommonItemView());
                }
                #region 原先错误的添加行
                //int maxColCount = InCommonNoteBiz.GetReportxmlCol(printInCommonViewClone);
                //if (maxColCount > 1 && maxColCount <= 5)
                //{
                //    if (maxColCount >= 2)
                //    {
                //        if (printInCommonViewClone.PrintInCommonTabViewList10 == null)
                //        { printInCommonViewClone.PrintInCommonTabViewList10 = new PrintInCommonTabView(); }
                //        if (printInCommonViewClone.PrintInCommonTabViewList10.PrintInCommonItemViewList == null)
                //        {

                //            printInCommonViewClone.PrintInCommonTabViewList10.PrintInCommonItemViewList = new List<PrintInCommonItemView>();
                //        }
                //        for (int i = 0; i < linecount; i++)
                //        {
                //            printInCommonViewClone.PrintInCommonTabViewList10.PrintInCommonItemViewList.Add(new PrintInCommonItemView());
                //        }
                //    }
                //    if (maxColCount >= 3)
                //    {
                //        if (printInCommonViewClone.PrintInCommonTabViewList9 == null)
                //        { printInCommonViewClone.PrintInCommonTabViewList9 = new PrintInCommonTabView(); }
                //        if (printInCommonViewClone.PrintInCommonTabViewList9.PrintInCommonItemViewList == null)
                //        {

                //            printInCommonViewClone.PrintInCommonTabViewList9.PrintInCommonItemViewList = new List<PrintInCommonItemView>();
                //        }
                //        for (int i = 0; i < linecount; i++)
                //        {
                //            printInCommonViewClone.PrintInCommonTabViewList9.PrintInCommonItemViewList.Add(new PrintInCommonItemView());
                //        }
                //    }
                //    if (maxColCount >= 4)
                //    {
                //        if (printInCommonViewClone.PrintInCommonTabViewList8 == null)
                //        { printInCommonViewClone.PrintInCommonTabViewList8 = new PrintInCommonTabView(); }
                //        if (printInCommonViewClone.PrintInCommonTabViewList8.PrintInCommonItemViewList == null)
                //        {

                //            printInCommonViewClone.PrintInCommonTabViewList8.PrintInCommonItemViewList = new List<PrintInCommonItemView>();
                //        }
                //        for (int i = 0; i < linecount; i++)
                //        {
                //            printInCommonViewClone.PrintInCommonTabViewList8.PrintInCommonItemViewList.Add(new PrintInCommonItemView());
                //        }
                //    } if (maxColCount >= 5)
                //    {
                //        if (printInCommonViewClone.PrintInCommonTabViewList7 == null)
                //        { printInCommonViewClone.PrintInCommonTabViewList7 = new PrintInCommonTabView(); }
                //        if (printInCommonViewClone.PrintInCommonTabViewList7.PrintInCommonItemViewList == null)
                //        {

                //            printInCommonViewClone.PrintInCommonTabViewList7.PrintInCommonItemViewList = new List<PrintInCommonItemView>();
                //        }
                //        for (int i = 0; i < linecount; i++)
                //        {
                //            printInCommonViewClone.PrintInCommonTabViewList7.PrintInCommonItemViewList.Add(new PrintInCommonItemView());
                //        }
                //  }
                //}
                #endregion
            }
            return(printInCommonViewClone);
        }
Exemple #10
0
        /// <summary>
        /// 计算ICU护理记录单的总量 并消除相同时间
        /// </summary>
        /// <param name="printInCommonView"></param>
        /// <returns></returns>
        public List <PrintInCommonItemView> JiSuanZongLiang(PrintInCommonView printInCommonView)
        {
            List <PrintInCommonItemView> printInCommonItemViewList    = printInCommonView.PrintInCommonTabViewList1.PrintInCommonItemViewList;
            List <PrintInCommonItemView> printInCommonItemViewListNew = new List <PrintInCommonItemView>();

            if (printInCommonItemViewList == null || printInCommonItemViewList.Count == 0)
            {
                return(printInCommonItemViewListNew);
            }
            //用于计算各列的总量
            decimal ZL20 = 0;
            decimal ZL22 = 0;
            decimal ZL23 = 0;
            decimal ZL28 = 0;
            decimal ZL29 = 0;
            decimal ZL31 = 0;
            decimal ZL32 = 0;

            decimal ZLW20 = 0;
            decimal ZLW22 = 0;
            decimal ZLW23 = 0;
            decimal ZLW28 = 0;
            decimal ZLW29 = 0;
            decimal ZLW31 = 0;
            decimal ZLW32 = 0;
            int     time1 = 7 * 60;  //晚上7点前和早上7点前计算总量
            int     time2 = 19 * 60; //晚上7点前和早上7点前计算总量

            //int LastTongJi = 0;  //标记上一条统计是何种统计 1早七点 2是晚七点 0为刚起步
            for (int i = 0; i < printInCommonItemViewList.Count; i++)
            {
                #region
                var     item = printInCommonItemViewList[i];
                decimal L20  = 0;
                decimal L22  = 0;
                decimal L23  = 0;
                decimal L28  = 0;
                decimal L29  = 0;
                decimal L31  = 0;
                decimal L32  = 0;

                decimal.TryParse(item.Value20, out L20);
                decimal.TryParse(item.Value22, out L22);
                decimal.TryParse(item.Value23, out L23);
                decimal.TryParse(item.Value28, out L28);
                decimal.TryParse(item.Value29, out L29);
                decimal.TryParse(item.Value31, out L31);
                decimal.TryParse(item.Value32, out L32);

                ZL20 += L20;
                ZL22 += L22;
                ZL23 += L23;
                ZL28 += L28;
                ZL29 += L29;
                ZL31 += L31;
                ZL32 += L32;

                ZLW20 += L20;
                ZLW22 += L22;
                ZLW23 += L23;
                ZLW28 += L28;
                ZLW29 += L29;
                ZLW31 += L31;
                ZLW32 += L32;

                string datetimeStr = item.DateTimeShow;


                printInCommonItemViewListNew.Add(item);

                if (!string.IsNullOrEmpty(datetimeStr) && datetimeStr.Length == 16 && i < printInCommonItemViewList.Count - 1)
                {
                    datetimeStr = datetimeStr + ":00";
                    DateTime dtime           = Convert.ToDateTime(datetimeStr);
                    string   datetimeNextStr = printInCommonItemViewList[i + 1].DateTimeShow + ":00";
                    DateTime dtNext          = Convert.ToDateTime(datetimeNextStr);

                    int dTimeMin     = dtime.Hour * 60 + dtime.Minute;
                    int dTimeMinNext = dtNext.Hour * 60 + dtNext.Minute;

                    if (i < printInCommonItemViewList.Count - 1 &&
                        printInCommonItemViewList[i + 1].DateTimeShow.Length == 16)
                    {
                        if ((dTimeMin <= time1 && dTimeMinNext > time1 && dtNext.Date == dtime.Date) || //同一天
                            (dTimeMin <= time1 && dtNext.Date > dtime.Date) ||
                            (dTimeMin > time2 && dTimeMinNext > time1 && dtNext.Date > dtime.Date))
                        {
                            PrintInCommonItemView printInCommonItemView = new CommonNoteUse.PrintInCommonItemView();
                            printInCommonItemView.IsZongLiang = 1;
                            printInCommonItemView.Date        = "早七点";
                            printInCommonItemView.Value1      = "统计";
                            printInCommonItemView.Time        = "";
                            printInCommonItemView.Value20     = ZL20.ToString();
                            printInCommonItemView.Value22     = ZL22.ToString();
                            printInCommonItemView.Value23     = ZL23.ToString();
                            printInCommonItemView.Value28     = ZL28.ToString();
                            printInCommonItemView.Value29     = ZL29.ToString();
                            printInCommonItemView.Value31     = ZL31.ToString();
                            printInCommonItemView.Value32     = ZL32.ToString();
                            printInCommonItemViewListNew.Add(printInCommonItemView);
                            ZL20 = 0;
                            ZL22 = 0;
                            ZL23 = 0;
                            ZL28 = 0;
                            ZL29 = 0;
                            ZL31 = 0;
                            ZL32 = 0;

                            ZLW20 = 0;
                            ZLW22 = 0;
                            ZLW23 = 0;
                            ZLW28 = 0;
                            ZLW29 = 0;
                            ZLW31 = 0;
                            ZLW32 = 0;
                        }
                        else if ((dTimeMin <= time2 && dTimeMinNext > time2 && dtNext.Date == dtime.Date) ||
                                 (dTimeMin <= time2 && dtNext.Date > dtime.Date))
                        {
                            PrintInCommonItemView printInCommonItemView = new CommonNoteUse.PrintInCommonItemView();
                            printInCommonItemView.IsZongLiang = 2;

                            printInCommonItemView.Date    = "晚七点";
                            printInCommonItemView.Value1  = "统计";
                            printInCommonItemView.Time    = "";
                            printInCommonItemView.Value20 = ZLW20.ToString();
                            printInCommonItemView.Value22 = ZLW22.ToString();
                            printInCommonItemView.Value23 = ZLW23.ToString();
                            printInCommonItemView.Value28 = ZLW28.ToString();
                            printInCommonItemView.Value29 = ZLW29.ToString();
                            printInCommonItemView.Value31 = ZLW31.ToString();
                            printInCommonItemView.Value32 = ZLW32.ToString();
                            printInCommonItemViewListNew.Add(printInCommonItemView);
                            ZLW20 = 0;
                            ZLW22 = 0;
                            ZLW23 = 0;
                            ZLW28 = 0;
                            ZLW29 = 0;
                            ZLW31 = 0;
                            ZLW32 = 0;

                            //ZL20 = 0;
                            //ZL22 = 0;
                            //ZL23 = 0;
                            //ZL28 = 0;
                            //ZL29 = 0;
                            //ZL31 = 0;
                            //ZL32 = 0;
                        }
                    }
                }
                #endregion
                //InCommonNoteBiz.ConvertForImgRec(printInCommonItemViewList[i]);

                //添加最后一条记录
                if (i == printInCommonItemViewList.Count - 1)
                {
                    datetimeStr = printInCommonItemViewList[printInCommonItemViewList.Count - 1].DateTimeShow + ":00";
                    DateTime dtime    = Convert.ToDateTime(datetimeStr);
                    int      dTimeMin = dtime.Hour * 60 + dtime.Minute;
                    PrintInCommonItemView printInCommonItemView = new CommonNoteUse.PrintInCommonItemView();
                    if (dTimeMin <= time1 || dTimeMin > time2)
                    {
                        printInCommonItemView.IsZongLiang = 1;
                        printInCommonItemView.Date        = "早七点";
                        printInCommonItemView.Value1      = "统计";
                        printInCommonItemView.Time        = "";

                        printInCommonItemView.Value20 = ZL20.ToString();
                        printInCommonItemView.Value22 = ZL22.ToString();
                        printInCommonItemView.Value23 = ZL23.ToString();
                        printInCommonItemView.Value28 = ZL28.ToString();
                        printInCommonItemView.Value29 = ZL29.ToString();
                        printInCommonItemView.Value31 = ZL31.ToString();
                        printInCommonItemView.Value32 = ZL32.ToString();

                        printInCommonItemViewListNew.Add(printInCommonItemView);
                        ZL20 = 0;
                        ZL22 = 0;
                        ZL23 = 0;
                        ZL28 = 0;
                        ZL29 = 0;
                        ZL31 = 0;
                        ZL32 = 0;
                    }
                    else
                    {
                        printInCommonItemView.IsZongLiang = 2;
                        printInCommonItemView.Date        = "晚七点";
                        printInCommonItemView.Value1      = "统计";
                        printInCommonItemView.Time        = "";

                        printInCommonItemView.Value20 = ZLW20.ToString();
                        printInCommonItemView.Value22 = ZLW22.ToString();
                        printInCommonItemView.Value23 = ZLW23.ToString();
                        printInCommonItemView.Value28 = ZLW28.ToString();
                        printInCommonItemView.Value29 = ZLW29.ToString();
                        printInCommonItemView.Value31 = ZLW31.ToString();
                        printInCommonItemView.Value32 = ZLW32.ToString();

                        printInCommonItemViewListNew.Add(printInCommonItemView);
                        ZLW20 = 0;
                        ZLW22 = 0;
                        ZLW23 = 0;
                        ZLW28 = 0;
                        ZLW29 = 0;
                        ZLW31 = 0;
                        ZLW32 = 0;
                    }
                }
            }
            //InCommonNoteBiz.ConvertForDateTime(printInCommonItemViewListNew);
            return(printInCommonItemViewListNew);
        }
        /// <summary>
        /// 计算ICU护理记录单的总量 并消除相同时间
        /// </summary>
        /// <param name="printInCommonView"></param>
        /// <returns></returns>
        public List <PrintInCommonItemView> JiSuanZongLiang(PrintInCommonView printInCommonView)
        {
            if (commonNoteCountEntity == null || commonNoteCountEntity.Valide != "1" || string.IsNullOrEmpty(commonNoteCountEntity.ItemCount))
            {
                return(printInCommonView.PrintInCommonTabViewList1.PrintInCommonItemViewList);
            }
            List <string> JiSuanColList = new List <string>();

            string[] strList = commonNoteCountEntity.ItemCount.Split(',', ',');
            foreach (var item in strList)
            {
                //避免统计列格式问题
                //XLB 2013-07-10
                int result = 0;
                if (!int.TryParse(item, out result))
                {
                    strList = strList.Where(p => p != item).ToArray();
                }
                else
                {
                    var colIndex = from jiSuanIndex in JiSuanColList where jiSuanIndex.Equals("Value" + item) select jiSuanIndex;
                    if (colIndex == null || colIndex.Count() <= 0)
                    {
                        JiSuanColList.Add("Value" + result);
                    }
                }
            }
            DateTime datetime1 = Convert.ToDateTime(commonNoteCountEntity.Hour12Time);
            DateTime datetime2 = Convert.ToDateTime(commonNoteCountEntity.Hour24Time);

            int time1 = datetime1.Hour * 60 + datetime1.Minute; //12小时统计
            int time2 = datetime2.Hour * 60 + datetime2.Minute; //24小时统计


            List <PrintInCommonItemView> printInCommonItemViewList    = printInCommonView.PrintInCommonTabViewList1.PrintInCommonItemViewList;
            List <PrintInCommonItemView> printInCommonItemViewListNew = new List <PrintInCommonItemView>();

            if (printInCommonItemViewList == null || printInCommonItemViewList.Count == 0)
            {
                return(printInCommonItemViewListNew);
            }



            Dictionary <string, decimal> ZL12DicList = new Dictionary <string, decimal>();
            Dictionary <string, decimal> ZL24DicList = new Dictionary <string, decimal>();

            foreach (var item in JiSuanColList)
            {
                ZL12DicList.Add(item, 0);
                ZL24DicList.Add(item, 0);
            }


            //int LastTongJi = 0;  //标记上一条统计是何种统计 1早七点 2是晚七点 0为刚起步
            for (int i = 0; i < printInCommonItemViewList.Count; i++)
            {
                #region
                var item = printInCommonItemViewList[i];


                foreach (var JiSuanCol in JiSuanColList)
                {
                    PropertyInfo property = item.GetType().GetProperty(JiSuanCol);
                    if (property != null)
                    {
                        decimal ValueDec = 0;
                        string  ValueStr = property.GetValue(item, null).ToString();
                        decimal.TryParse(ValueStr, out ValueDec);
                        ZL12DicList[JiSuanCol] += ValueDec;
                        ZL24DicList[JiSuanCol] += ValueDec;
                    }
                }

                string datetimeStr = item.DateTimeShow;


                printInCommonItemViewListNew.Add(item);

                if (!string.IsNullOrEmpty(datetimeStr) && datetimeStr.Length == 16 && i < printInCommonItemViewList.Count - 1)
                {
                    datetimeStr = datetimeStr + ":00";
                    DateTime dtime           = Convert.ToDateTime(datetimeStr);
                    string   datetimeNextStr = printInCommonItemViewList[i + 1].DateTimeShow + ":00";
                    DateTime dtNext          = Convert.ToDateTime(datetimeNextStr);

                    int dTimeMin     = dtime.Hour * 60 + dtime.Minute;
                    int dTimeMinNext = dtNext.Hour * 60 + dtNext.Minute;

                    if (i < printInCommonItemViewList.Count - 1 &&
                        printInCommonItemViewList[i + 1].DateTimeShow.Length == 16)
                    {
                        if ((dTimeMin <= time1 && dTimeMinNext > time1 && dtNext.Date == dtime.Date) || //同一天  12小时统计
                            (dTimeMin <= time1 && dtNext.Date > dtime.Date) ||
                            (dTimeMin > time2 && dTimeMinNext > time1 && dtNext.Date > dtime.Date) ||
                            (dTimeMin > time2 && dtNext.Date.AddDays(-1) > dtime.Date))
                        {
                            PrintInCommonItemView printInCommonItemView = new CommonNoteUse.PrintInCommonItemView();
                            printInCommonItemView.IsZongLiang = 1;

                            if (commonNoteCountEntity.Hour12Name.Length >= 6)
                            {
                                printInCommonItemView.Date = commonNoteCountEntity.Hour12Name.Substring(0, 6);
                                printInCommonItemView.Time = commonNoteCountEntity.Hour12Name.Substring(6);
                            }
                            else
                            {
                                printInCommonItemView.Date = commonNoteCountEntity.Hour12Name;
                            }
                            printInCommonItemView.DateTimeShow = commonNoteCountEntity.Hour12Name;

                            bool Is12HasCount = false;
                            foreach (var jisuancol in JiSuanColList)
                            {
                                PropertyInfo property = printInCommonItemView.GetType().GetProperty(jisuancol);
                                property.SetValue(printInCommonItemView, ZL12DicList[jisuancol].ToString(), null);
                                if (ZL12DicList[jisuancol] > 0)
                                {
                                    Is12HasCount = true;
                                }
                                ZL12DicList[jisuancol] = 0;
                                //视情况清空24小时统计
                                if (dtNext.Date.AddDays(-1) > dtime.Date)
                                {
                                    ZL24DicList[jisuancol] = 0;
                                }
                            }
                            if (Is12HasCount)  //如果需要计算的列 有一个不等于0 就显示 否则不显示统计列
                            {
                                printInCommonItemViewListNew.Add(printInCommonItemView);
                            }
                        }
                        else if ((dTimeMin <= time2 && dTimeMinNext > time2 && dtNext.Date == dtime.Date) ||
                                 (dTimeMin <= time2 && dtNext.Date > dtime.Date))
                        {
                            PrintInCommonItemView printInCommonItemView = new CommonNoteUse.PrintInCommonItemView();
                            printInCommonItemView.IsZongLiang = 2;

                            if (commonNoteCountEntity.Hour24Name.Length >= 4)
                            {
                                printInCommonItemView.Date = commonNoteCountEntity.Hour24Name.Substring(0, 6);
                                printInCommonItemView.Time = commonNoteCountEntity.Hour24Name.Substring(6);
                            }
                            else
                            {
                                printInCommonItemView.Date = commonNoteCountEntity.Hour24Name;
                            }
                            printInCommonItemView.DateTimeShow = commonNoteCountEntity.Hour24Name;

                            bool IsJisuan24 = false;
                            foreach (var jisuancol in JiSuanColList)
                            {
                                PropertyInfo property = printInCommonItemView.GetType().GetProperty(jisuancol);
                                property.SetValue(printInCommonItemView, ZL24DicList[jisuancol].ToString(), null);
                                if (ZL24DicList[jisuancol] > 0)
                                {
                                    IsJisuan24 = true;
                                }
                                ZL12DicList[jisuancol] = 0;
                                ZL24DicList[jisuancol] = 0;
                            }
                            if (IsJisuan24)
                            {
                                printInCommonItemViewListNew.Add(printInCommonItemView);
                            }
                        }
                    }
                }
                #endregion
                //InCommonNoteBiz.ConvertForImgRec(printInCommonItemViewList[i]);

                //添加最后一条记录
                if (i == printInCommonItemViewList.Count - 1)
                {
                    datetimeStr = printInCommonItemViewList[printInCommonItemViewList.Count - 1].DateTimeShow + ":00";
                    DateTime dtime    = Convert.ToDateTime(datetimeStr);
                    int      dTimeMin = dtime.Hour * 60 + dtime.Minute;
                    PrintInCommonItemView printInCommonItemView = new CommonNoteUse.PrintInCommonItemView();
                    if (dTimeMin <= time1 || dTimeMin > time2)
                    {
                        printInCommonItemView.IsZongLiang = 1;

                        if (commonNoteCountEntity.Hour12Name.Length >= 6)
                        {
                            printInCommonItemView.Date = commonNoteCountEntity.Hour12Name.Substring(0, 6);
                            printInCommonItemView.Time = commonNoteCountEntity.Hour12Name.Substring(6);
                        }
                        else
                        {
                            printInCommonItemView.Date = commonNoteCountEntity.Hour12Name;
                        }
                        printInCommonItemView.DateTimeShow = commonNoteCountEntity.Hour12Name;
                        bool IsJisuan12 = false;
                        foreach (var jisuancol in JiSuanColList)
                        {
                            PropertyInfo property = printInCommonItemView.GetType().GetProperty(jisuancol);
                            property.SetValue(printInCommonItemView, ZL12DicList[jisuancol].ToString(), null);
                            if (ZL12DicList[jisuancol] > 0)
                            {
                                IsJisuan12 = true;
                            }
                            ZL12DicList[jisuancol] = 0;
                        }
                        if (IsJisuan12)
                        {
                            printInCommonItemViewListNew.Add(printInCommonItemView);
                        }
                    }
                    else
                    {
                        printInCommonItemView.IsZongLiang = 2;

                        if (commonNoteCountEntity.Hour24Name.Length >= 6)
                        {
                            printInCommonItemView.Date = commonNoteCountEntity.Hour24Name.Substring(0, 6);
                            printInCommonItemView.Time = commonNoteCountEntity.Hour24Name.Substring(6);
                        }
                        else
                        {
                            printInCommonItemView.Date = commonNoteCountEntity.Hour24Name;
                        }
                        printInCommonItemView.DateTimeShow = commonNoteCountEntity.Hour24Name;

                        bool Isjisuan24 = false;
                        foreach (var jisuancol in JiSuanColList)
                        {
                            PropertyInfo property = printInCommonItemView.GetType().GetProperty(jisuancol);
                            property.SetValue(printInCommonItemView, ZL24DicList[jisuancol].ToString(), null);
                            if (ZL24DicList[jisuancol] > 0)
                            {
                                Isjisuan24 = true;
                            }
                            ZL24DicList[jisuancol] = 0;
                        }
                        if (Isjisuan24)
                        {
                            printInCommonItemViewListNew.Add(printInCommonItemView);
                        }
                    }
                }
            }
            //InCommonNoteBiz.ConvertForDateTime(printInCommonItemViewListNew);
            return(printInCommonItemViewListNew);
        }
Exemple #12
0
        /// <summary>
        /// 计算危重护理记录单的总量 并消除相同时间
        /// </summary>
        /// <param name="printInCommonView"></param>
        /// <returns></returns>
        public List <PrintInCommonItemView> JiSuanZongLiang(PrintInCommonView printInCommonView)
        {
            List <PrintInCommonItemView> printInCommonItemViewList    = printInCommonView.PrintInCommonTabViewList1.PrintInCommonItemViewList;
            List <PrintInCommonItemView> printInCommonItemViewListNew = new List <PrintInCommonItemView>();

            if (printInCommonItemViewList == null || printInCommonItemViewList.Count == 0)
            {
                return(printInCommonItemViewListNew);
            }
            //用于计算各列的总量
            decimal ZL11  = 0;
            decimal ZL13  = 0;
            int     time1 = 7 * 60;  //晚上7点前和早上7点前计算总量
            int     time2 = 19 * 60; //晚上7点前和早上7点前计算总量

            for (int i = 0; i < printInCommonItemViewList.Count; i++)
            {
                #region
                var     item = printInCommonItemViewList[i];
                decimal L11  = 0;
                decimal L13  = 0;


                decimal.TryParse(item.Value11, out L11);
                decimal.TryParse(item.Value13, out L13);
                ZL11 += L11;
                ZL13 += L13;

                string datetimeStr = item.DateTimeShow;


                printInCommonItemViewListNew.Add(item);

                if (!string.IsNullOrEmpty(datetimeStr) && datetimeStr.Length == 16 && i < printInCommonItemViewList.Count - 1)
                {
                    datetimeStr = datetimeStr + ":00";
                    DateTime dtime           = Convert.ToDateTime(datetimeStr);
                    string   datetimeNextStr = printInCommonItemViewList[i + 1].DateTimeShow + ":00";
                    DateTime dtNext          = Convert.ToDateTime(datetimeNextStr);

                    int dTimeMin     = dtime.Hour * 60 + dtime.Minute;
                    int dTimeMinNext = dtNext.Hour * 60 + dtNext.Minute;

                    if (i < printInCommonItemViewList.Count - 1 &&
                        printInCommonItemViewList[i + 1].DateTimeShow.Length == 16)
                    {
                        if ((dTimeMin <= time1 && dTimeMinNext > time1 && dtNext.Date == dtime.Date) ||
                            (dTimeMin <= time1 && dtNext.Date > dtime.Date) ||
                            (dTimeMin > time2 && dTimeMinNext > time1 && dtNext.Date > dtime.Date))
                        {
                            PrintInCommonItemView printInCommonItemView = new CommonNoteUse.PrintInCommonItemView();
                            printInCommonItemView.IsZongLiang = 1;
                            printInCommonItemView.Date        = "早七点";
                            printInCommonItemView.Time        = "统计";
                            printInCommonItemView.Value10     = "总入量";
                            printInCommonItemView.Value11     = ZL11.ToString();
                            printInCommonItemView.Value12     = "总出量";
                            printInCommonItemView.Value13     = ZL13.ToString();
                            printInCommonItemViewListNew.Add(printInCommonItemView);
                            ZL11 = 0;
                            ZL13 = 0;
                        }
                        else if ((dTimeMin <= time2 && dTimeMinNext > time2 && dtNext.Date == dtime.Date) ||
                                 (dTimeMin <= time2 && dtNext.Date > dtime.Date))
                        {
                            PrintInCommonItemView printInCommonItemView = new CommonNoteUse.PrintInCommonItemView();
                            printInCommonItemView.IsZongLiang = 2;
                            printInCommonItemView.Date        = "晚七点";
                            printInCommonItemView.Time        = "统计";
                            printInCommonItemView.Value10     = "总入量";
                            printInCommonItemView.Value11     = ZL11.ToString();
                            printInCommonItemView.Value12     = "总出量";
                            printInCommonItemView.Value13     = ZL13.ToString();
                            printInCommonItemViewListNew.Add(printInCommonItemView);
                            ZL11 = 0;
                            ZL13 = 0;
                        }
                    }
                }
                #endregion
                //InCommonNoteBiz.ConvertForImgRec(printInCommonItemViewList[i]);

                //添加最后一条记录
                if (i == printInCommonItemViewList.Count - 1)
                {
                    datetimeStr = printInCommonItemViewList[printInCommonItemViewList.Count - 1].DateTimeShow + ":00";
                    DateTime dtime    = Convert.ToDateTime(datetimeStr);
                    int      dTimeMin = dtime.Hour * 60 + dtime.Minute;
                    PrintInCommonItemView printInCommonItemView = new CommonNoteUse.PrintInCommonItemView();
                    if (dTimeMin <= time1 || dTimeMin > time2)
                    {
                        printInCommonItemView.IsZongLiang = 1;
                        printInCommonItemView.Date        = "早七点";
                        printInCommonItemView.Time        = "统计";
                    }
                    else
                    {
                        printInCommonItemView.IsZongLiang = 2;
                        printInCommonItemView.Date        = "晚七点";
                        printInCommonItemView.Time        = "统计";
                    }
                    printInCommonItemView.Value10 = "总入量";
                    printInCommonItemView.Value11 = ZL11.ToString();
                    printInCommonItemView.Value12 = "总出量";
                    printInCommonItemView.Value13 = ZL13.ToString();
                    printInCommonItemViewListNew.Add(printInCommonItemView);
                    ZL11 = 0;
                    ZL13 = 0;
                }
            }
            //InCommonNoteBiz.ConvertForDateTime(printInCommonItemViewListNew);
            return(printInCommonItemViewListNew);
        }