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);
        }
示例#2
0
 /// <summary>
 /// 填充数据(查看修改)
 /// </summary>
 private void FillData(Guid guid)
 {
     Voucher        = new PA.ViewModel.ViewModel_凭证管理().GetVoucher(guid);
     VoucherDetails = new PA.ViewModel.ViewModel_凭证管理().GetVoucherDetails(guid);
     this.DatePicker_Date.SelectedDate = Voucher.制表时间;
     this.TextBox_附属单证.Text            = Voucher.附属单证数.ToString();
     this.Label_借方合计.Content           = Voucher.合计借方金额.ToString().Contains(".") ? Voucher.合计借方金额.ToString("f2") : Voucher.合计借方金额.ToString();
     this.Label_贷方合计.Content           = Voucher.合计贷方金额.ToString().Contains(".") ? Voucher.合计贷方金额.ToString("f2") : Voucher.合计贷方金额.ToString();
     for (int i = 0; i < 6; i++)
     {
         Model_凭证明细 a = new Model_凭证明细();
         a.序号 = i;
         VoucherDetailsNow.Add(a);
     }
     for (int i = 0; i < VoucherDetails.Count; i++)
     {
         if (i < 6)
         {
             VoucherDetailsNow[i] = VoucherDetails[i];
         }
     }
     this.TextBox_号.Text            = VoucherDetailsNow[0].凭证号;
     this.DataGrid_凭证明细.ItemsSource = VoucherDetailsNow;
     PageAll = new PA.ViewModel.ViewModel_凭证管理().GetPageNum(guid);
     this.TextBlock_PageNum.Text = "1/" + PageAll;
     if (Voucher.审核标志 == 1)
     {
         this.Label_审核状态.Content    = "已审核";
         this.Label_审核状态.Foreground = Brushes.Green;
     }
     else
     {
         this.Label_审核状态.Content    = "未审核";
         this.Label_审核状态.Foreground = Brushes.Red;
     }
     //已审核,不能编辑修改
     if (Voucher.审核标志 == 1)
     {
         this.Button_保存.Visibility          = System.Windows.Visibility.Collapsed;
         this.Button_NewDataGrid.Visibility = System.Windows.Visibility.Collapsed;
         this.TextBox_号.IsReadOnly          = true;
         this.TextBox_附属单证.IsReadOnly       = true;
         this.DataGrid_凭证明细.IsReadOnly      = true;
         this.DatePicker_Date.IsEnabled     = false;
     }
     this.Label_会计主管.Content = Voucher.会计主管;
     this.Label_制单人.Content  = Voucher.制单人;
     this.Label_复核.Content   = Voucher.核;
 }
        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);
        }