Exemple #1
0
        /// <summary>
        /// 作用:添加BillTwo  存在则替换  不存在追加
        /// 作者:汪建龙
        /// 编写时间:2016年12月11日14:34:54
        /// </summary>
        /// <param name="billTwo"></param>
        /// <returns></returns>
        public int Add(BillTwo billTwo)
        {
            if (billTwo != null)
            {
                return(Core.Bill_RecordManager.Add(new BillRecord
                {
                    ID = billTwo.ID,
                    SerialNumber = billTwo.SerialNumber,

                    Date = billTwo.Date,
                    Time = billTwo.Time,

                    Budget = billTwo.Budget,
                    Money = billTwo.Money,

                    Balance = billTwo.Balance,
                    Account = billTwo.Account,

                    Summary = billTwo.Summary,
                    Remark = billTwo.Remark,

                    Remark2 = billTwo.Remark2,
                    HID = billTwo.HID,

                    Cost = billTwo.Cost,
                    //Category = billTwo.Category,

                    TimeStamp = billTwo.TimeStamp,
                    CommissionCharge = billTwo.CommissionCharge,

                    Way = billTwo.Way,
                    Bank = billTwo.Bank,

                    Type = billTwo.Type,
                    Address = billTwo.Address,

                    Name = billTwo.Name,
                    PostScript = billTwo.PostScript,
                    Sync = billTwo.Sync
                }));
            }
            return(0);
            //using (var db = GetDbContext())
            //{
            //    var entry = db.BillTwos.FirstOrDefault(e => e.SerialNumber == billTwo.SerialNumber && e.HID == billTwo.HID);
            //    if (entry != null)
            //    {
            //        billTwo.ID = entry.ID;
            //        db.Entry(entry).CurrentValues.SetValues(billTwo);
            //    }
            //    else
            //    {
            //        db.BillTwos.Add(billTwo);
            //    }
            //    db.SaveChanges();
            //    return billTwo.ID;
            //}
        }
Exemple #2
0
        /// <summary>
        /// 作用:将规划公司银行对账单导入
        /// 作者:汪建龙
        /// 编写时间:2016年12月11日14:36:41
        /// </summary>
        /// <param name="hid"></param>
        /// <param name="list"></param>
        /// <param name="year"></param>
        /// <param name="month"></param>
        /// <returns></returns>
        public List <string> Input2(int hid, List <BillTwo> list, int year, int month, Company company)
        {
            var     errors          = new List <string>();
            var     preSerialNumber = 1;
            BillTwo preEntry        = null;

            foreach (var item in list)
            {
                var error = string.Empty;
                if (preEntry != null)
                {
                    if (!BillClass.CheckLogic(item, preEntry))
                    {
                        error = "序号前后不一致,应递增或者账户月收支前后不一致;";
                    }
                    if (!BillClass.CheckTime(item, year, month))
                    {
                        error += string.Format("交易日期不在{0}年{1}月,请核对!", year, month);
                    }
                }
                else
                {
                    if (item.SerialNumber == 1)
                    {
                        BillRecord last = null;
                        if (month == 1)
                        {
                            last = Core.Bill_RecordManager.GetLast(year - 1, 12, company);
                        }
                        else
                        {
                            last = Core.Bill_RecordManager.GetLast(year, month - 1, company);
                        }
                        if (last != null)
                        {
                            if (!BillClass.CheckLogic(last, item))
                            {
                                error += string.Format("当前月初第一笔收支与上个月不符,请核对!");
                            }
                        }
                    }
                }
                if (!string.IsNullOrEmpty(error))
                {
                    errors.Add(string.Format("第{0}个数据存在如下错误:{1}", preSerialNumber, error));
                    continue;
                }
                item.HID = hid;
                if (Add(item) == 0)
                {
                    errors.Add(string.Format("第{0}个数据:保存到数据库失败;", preSerialNumber));
                }
                preEntry = item;
                preSerialNumber++;
            }
            return(errors);
        }