Пример #1
0
        // 根据XML片段,创建OverdueItems对象数组
        /// <summary>
        /// 根据 XML 片断,创建超期事项集合
        /// </summary>
        /// <param name="strOverdueString">XML片断</param>
        /// <param name="strError">返回出错信息</param>
        /// <returns>-1: 出错 0: 成功</returns>
        public int BuildOverdueItems(string strOverdueString,
                                     out string strError)
        {
            strError = "";
            this.OverdueItems.Clear();

            if (String.IsNullOrEmpty(strOverdueString) == true)
            {
                return(0);
            }

            XmlDocument dom = new XmlDocument();

            dom.LoadXml("<root/>");

            XmlDocumentFragment fragment = dom.CreateDocumentFragment();

            try
            {
                fragment.InnerXml = strOverdueString;
            }
            catch (Exception ex)
            {
                strError = "PrintHost BuildOverdueItems() fragment.InnerXml set exception: " + ExceptionUtil.GetAutoText(ex);
                return(-1);
            }

            // 插入到最前面
            DomUtil.InsertFirstChild(dom.DocumentElement, fragment);

            XmlNodeList nodes = dom.DocumentElement.SelectNodes("overdue");

            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node = nodes[i];

                OverdueItemInfo info = new OverdueItemInfo();
                info.ItemBarcode    = DomUtil.GetAttr(node, "barcode");
                info.RecPath        = DomUtil.GetAttr(node, "recPath");
                info.Reason         = DomUtil.GetAttr(node, "reason");
                info.Price          = DomUtil.GetAttr(node, "price");
                info.BorrowDate     = DomUtil.GetAttr(node, "borrowDate");
                info.BorrowPeriod   = DomUtil.GetAttr(node, "borrowPeriod");
                info.ReturnDate     = DomUtil.GetAttr(node, "returnDate");
                info.BorrowOperator = DomUtil.GetAttr(node, "borrowOperator");
                info.ReturnOperator = DomUtil.GetAttr(node, "operator");
                info.ID             = DomUtil.GetAttr(node, "id");

                // 2008/11/15
                info.Comment = DomUtil.GetAttr(node, "comment");

                this.OverdueItems.Add(info);
            }

            return(0);
        }
Пример #2
0
        // 根据XML片段,创建OverdueItems对象数组
        /// <summary>
        /// 根据 XML 片断,创建超期事项集合
        /// </summary>
        /// <param name="strOverdueString">XML片断</param>
        /// <param name="strError">返回出错信息</param>
        /// <returns>-1: 出错 0: 成功</returns>
        public int BuildOverdueItems(string strOverdueString,
            out string strError)
        {
            strError = "";
            this.OverdueItems.Clear();

            if (String.IsNullOrEmpty(strOverdueString) == true)
                return 0;

            XmlDocument dom = new XmlDocument();
            dom.LoadXml("<root/>");

            XmlDocumentFragment fragment = dom.CreateDocumentFragment();
            try
            {
                fragment.InnerXml = strOverdueString;
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                return -1;
            }

            // 插入到最前面
            DomUtil.InsertFirstChild(dom.DocumentElement, fragment);

            XmlNodeList nodes = dom.DocumentElement.SelectNodes("overdue");
            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node = nodes[i];

                OverdueItemInfo info = new OverdueItemInfo();
                info.ItemBarcode = DomUtil.GetAttr(node, "barcode");
                info.RecPath = DomUtil.GetAttr(node, "recPath");
                info.Reason = DomUtil.GetAttr(node, "reason");
                info.Price = DomUtil.GetAttr(node, "price");
                info.BorrowDate = DomUtil.GetAttr(node, "borrowDate");
                info.BorrowPeriod = DomUtil.GetAttr(node, "borrowPeriod");
                info.ReturnDate = DomUtil.GetAttr(node, "returnDate");
                info.BorrowOperator = DomUtil.GetAttr(node, "borrowOperator");
                info.ReturnOperator = DomUtil.GetAttr(node, "operator");
                info.ID = DomUtil.GetAttr(node, "id");

                // 2008/11/15
                info.Comment = DomUtil.GetAttr(node, "comment");

                this.OverdueItems.Add(info);
            }

            return 0;
        }
Пример #3
0
        // 获得显示用的信息
        // parameters:
        int GetCheckedOverdueInfos(ListView listview,
            out List<OverdueItemInfo> overdue_infos,
            out string strError)
        {
            strError = "";
            overdue_infos = new List<OverdueItemInfo>();
            int nCheckedCount = 0;

            // 目前两个listview的id列都还是8
            for (int i = 0; i < listview.Items.Count; i++)
            {
                ListViewItem item = listview.Items[i];
                if (item.Checked == false)
                    continue;

                string strID = "";
                string strPrice = "";
                string strComment = "";
                if (listview == this.listView_amerced)
                {
                    // strID = listview.Items[i].SubItems[8].Text;
                    // strPriceComment = listview.Items[i].SubItems[2].Text;
                    strID = ListViewUtil.GetItemText(item, COLUMN_AMERCED_ID);
                    strPrice = ListViewUtil.GetItemText(item, COLUMN_AMERCED_PRICE);
                    if (string.IsNullOrEmpty(strPrice) == false)
                    {
                        string strResultPrice = "";
                        // 将形如"-123.4+10.55-20.3"的价格字符串反转正负号
                        // parameters:
                        //      bSum    是否要顺便汇总? true表示要汇总
                        int nRet = PriceUtil.NegativePrices(strPrice,
                            false,
                            out strResultPrice,
                            out strError);
                        if (nRet == -1)
                            strPrice = "-(" + strPrice + ")";
                        else
                            strPrice = strResultPrice;
                    }
                    strComment = ListViewUtil.GetItemText(item, COLUMN_AMERCED_COMMENT);
                    if (string.IsNullOrEmpty(strComment) == true)
                        strComment = "撤回交费";
                    else
                        strComment = "撤回交费 (" + strComment + ")";
                }
                else
                {
                    Debug.Assert(listview == this.listView_overdues, "");
                    strID = ListViewUtil.GetItemText(item, COLUMN_AMERCING_ID);
                    strPrice = ListViewUtil.GetItemText(item, COLUMN_AMERCING_PRICE);
                    strComment = ListViewUtil.GetItemText(item, COLUMN_AMERCING_COMMENT);
                }

                if (String.IsNullOrEmpty(strID) == true)
                {
                    strError = "出现了id为空的行。";
                    return -1;
                }

                // 有星号的是变更金额
                strPrice = RemoveChangedMask(strPrice);

                OverdueItemInfo info = new OverdueItemInfo();
                info.Price = strPrice;
                info.ItemBarcode = ListViewUtil.GetItemText(item,
                    COLUMN_AMERCING_ITEMBARCODE);
                info.RecPath = ""; // recPath
                info.Reason = ListViewUtil.GetItemText(item,
                    COLUMN_AMERCING_REASON);

                info.BorrowDate = ListViewUtil.GetItemText(item,
                    COLUMN_AMERCING_BORROWDATE);
                info.BorrowPeriod = ListViewUtil.GetItemText(item,
                    COLUMN_AMERCING_BORROWPERIOD);
                info.ReturnDate = ListViewUtil.GetItemText(item,
                    COLUMN_AMERCING_RETURNDATE);
                info.BorrowOperator = ListViewUtil.GetItemText(item,
                    COLUMN_AMERCING_BORROWOPERATOR);  // borrowOperator
                info.ReturnOperator = ListViewUtil.GetItemText(item,
                    COLUMN_AMERCING_RETURNOPERATOR);    // operator
                info.ID = ListViewUtil.GetItemText(item,
                    COLUMN_AMERCING_ID);

                // 2008/11/15
                info.Comment = strComment;

                overdue_infos.Add(info);

                nCheckedCount++;
            }

            return nCheckedCount;
        }