コード例 #1
0
 void SetEndBill()
 {
     if (!string.IsNullOrEmpty(txtStartBill.Text))
     {
         var start = BaseBusinessLogic.ConvertToLong(txtStartBill.Text);
         var end   = start + BaseBusinessLogic.ConvertToLong(cmbPrintBillCount.Text);
         lblTotal.Text   = "总计:" + cmbPrintBillCount.Text;
         txtEndBill.Text = end.ToString();
     }
 }
コード例 #2
0
 /// <summary>
 /// 光标离开自动计算数量
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtEndBill_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtStartBill.Text) && !string.IsNullOrEmpty(txtStartBill.Text))
     {
         var start = BaseBusinessLogic.ConvertToLong(txtStartBill.Text);
         var end   = BaseBusinessLogic.ConvertToLong(txtEndBill.Text);
         var count = end - start;
         lblTotal.Text = "总计:" + count;
         btnSaveBill.Focus();
     }
 }
コード例 #3
0
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSaveBill_Click(object sender, EventArgs e)
 {
     if (this.PrintBillEntities.Any())
     {
         var start = BaseBusinessLogic.ConvertToLong(txtStartBill.Text);
         var end   = BaseBusinessLogic.ConvertToLong(txtEndBill.Text);
         var count = end - start;
         if (count.ToString() == cmbPrintBillCount.Text)
         {
             for (int i = 0; i < PrintBillEntities.Count; i++)
             {
                 var billCode = BaseBusinessLogic.ConvertToLong(txtStartBill.Text) + i;
                 PrintBillEntities[i].BillCode = billCode.ToString();
             }
             if (MessageUtil.ConfirmYesNo(string.Format("确定保存{0}条单号吗?", PrintBillEntities.Count)))
             {
                 using (IDbHelper dbHelper = DbHelperFactory.GetHelper(CurrentDbType.SQLite, BillPrintHelper.BillPrintConnectionString))
                 {
                     try
                     {
                         dbHelper.BeginTransaction();
                         var manager = new ZtoPrintBillManager(dbHelper);
                         foreach (var itemBill in PrintBillEntities)
                         {
                             manager.SetProperty(new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldId, itemBill.Id), new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldBillCode, itemBill.BillCode));
                         }
                         dbHelper.CommitTransaction();
                         MessageUtil.ShowTips("保存成功");
                     }
                     catch (Exception ex)
                     {
                         dbHelper.RollbackTransaction();
                         LogUtil.WriteException(ex);
                     }
                 }
             }
         }
         else
         {
             string error = string.Format("需要打印{0},结束单号-开始单号和需要打印数据不相等,不能保存", PrintBillEntities.Count);
             MessageUtil.ShowError(error);
         }
     }
 }