internal bool InsertData(Model_凭证单 Voucher, List<Model_凭证明细> VoucherDetails) { bool isEmpty = true; decimal CountBorrow = 0m; decimal CountLoan = 0m; List<Model_凭证明细> NewVoucherDetails = new List<Model_凭证明细>(); foreach (Model_凭证明细 VoucherDetail in VoucherDetails) { if (VoucherDetail.科目编号 != null) { NewVoucherDetails.Add(VoucherDetail); CountBorrow += VoucherDetail.借方; CountLoan += VoucherDetail.贷方; isEmpty = false; } } if (!isEmpty) { if (CountBorrow != CountLoan) { return false; } List<Model_凭证单> Vouchers = new List<Model_凭证单>(); Vouchers.Add(Voucher); bool result = new PA.Helper.DataBase.DataBase().InsertVoucherAll(Vouchers.OfType<object>().ToList(), NewVoucherDetails.OfType<object>().ToList()); if(!result) { return false; } } return !isEmpty; }
internal Model_凭证单 GetVoucher(Guid guid) { Model_凭证单 Voucher = new Model_凭证单(); string sql = "select * from " + DBTablesName.T_VOUCHER + " where id='" + guid + "'"; DataSet ds = new PA.Helper.DataBase.DataBase().Query(sql); foreach (DataRow dr in ds.Tables[0].Rows) { Voucher.ID = dr[0].ToString(); Voucher.当前期 = int.Parse(dr[1].ToString()); Voucher.制表时间 = Convert.ToDateTime(dr[2]); Voucher.附属单证数 = int.Parse(dr[3].ToString()); Voucher.合计借方金额 = decimal.Parse(dr[4].ToString()); Voucher.合计贷方金额 = decimal.Parse(dr[5].ToString()); Voucher.会计主管 = dr[6].ToString(); Voucher.制单人 = dr[7].ToString(); Voucher.复核 = dr[8].ToString(); Voucher.审核标志 = int.Parse(dr[9].ToString()); Voucher.删除标志 = int.Parse(dr[10].ToString()); } return Voucher; }