protected override bool Create() { var bl = new PurchaseBillBL(); this.Current = bl.Create(); this.Original = CopyBill(this.Current); return(this.Current != null); }
protected override bool GetByID(int id) { var bl = new PurchaseBillBL(); this.Current = bl.GetByID(id); this.Original = CopyBill(this.Current); return(this.Current != null); }
protected override ResultMessage CheckValid() { if (txtSupplier.Text == string.Empty) { var message = string.Format("'{0}'未填写,不能保存", txtSupplier.LabelText); txtSupplier.Focus(); return(new ResultMessage(false, message)); } //else if (txtBillCode.Text == string.Empty) //{ // txtBillCode.Focus(); // Utility.ShowError(string.Format("'{0}'未填写,不能保存", txtBillCode.LabelText), this); // return false; //} //else if (BillDate) //{ //} else if (dataGridView2.RowCount == 1) { var message = "'单据明细'未填写,不能保存"; if (dataGridView2.CanFocus) { dataGridView2.Focus(); } return(new ResultMessage(false, message)); } else { for (int i = 0; i < dataGridView2.RowCount - 1; i++) { var row = dataGridView2.Rows[i]; if (Convert.ToString(row.Cells["colProductName"].Value) == string.Empty) { var message = string.Format("明细第{0}行 '商品名称'未填写,不能保存", i + 1); dataGridView2.CurrentCell = dataGridView2.Rows[i].Cells["colProductName"]; return(new ResultMessage(false, message)); } else if (Convert.ToDecimal(row.Cells["colUnitPrice"].Value) <= 0) { var message = string.Format("明细第{0}行 '单价'小于零或等于零,不能保存", i + 1); dataGridView2.CurrentCell = dataGridView2.Rows[i].Cells["colUnitPrice"]; return(new ResultMessage(false, message)); } else if (Convert.ToDecimal(row.Cells["colQuantity"].Value) <= 0) { var message = string.Format("明细第{0}行 '数量'小于零或等于零,不能保存", i + 1); dataGridView2.CurrentCell = dataGridView2.Rows[i].Cells["colQuantity"]; return(new ResultMessage(false, message)); } } } var bl = new PurchaseBillBL(); return(bl.CheckValid(this.Current)); }
protected override ResultMessage Delete() { var bl = new PurchaseBillBL(); var rm = bl.Delete(this.Current); if (rm.Result) { //this.Original = CopyEntity(this.Current); } return(rm); }
protected override ResultMessage Save_Update() { before_Save(); var bl = new PurchaseBillBL(); var rm = bl.Update(this.Original, this.Current); if (rm.Result) { this.Original = CopyBill(this.Current); } return(rm); }
protected override IEnumerable GetItemList(int rowIndex) { int id = 0; if ((dataGridView1.RowCount > 0) && (rowIndex < dataGridView1.RowCount) && (dataGridView1.Rows[rowIndex].DataBoundItem is PurchaseBill)) { id = (dataGridView1.Rows[rowIndex].DataBoundItem as PurchaseBill).PurchaseID; } var bl = new PurchaseBillBL(); var list = bl.GetItemList(id); return(list); }
protected override ResultMessage Save_Create() { before_Save(); var bl = new PurchaseBillBL(); int newID = 0; var rm = bl.Insert(this.Current, out newID); if (rm.Result) { this.Current.PurchaseID = newID; this.Original = CopyBill(this.Current); } return(rm); }
protected override IEnumerable GetRows() { var where = "BillDate BETWEEN '" + dtpBillDate1.Value.Date.ToString() + "' AND dateadd(day, 1, '" + dtpBillDate2.Value.Date.ToString() + "')"; var s = txtSupplierName.Text.Trim(); if (s != "") { where += " AND SupplierName LIKE '%" + s + "%'"; } var orderby = "BillDate ASC"; var bl = new PurchaseBillBL(); var list = bl.GetList(where, orderby); return(list); }
protected override IEnumerable GetList() { var filters = "BillDate >= '" + dtpBillDate1.Value.Date.ToString() + "' AND BillDate < dateadd(day, 1, '" + dtpBillDate2.Value.Date.ToString() + "')"; var s = txtSupplierName.Text.Trim(); if (s != string.Empty) { if (filters != string.Empty) { filters += " AND "; } filters += "SupplierName LIKE '%" + s + "%'"; } var sorts = "BillDate DESC, BillCode, SupplierName"; var bl = new PurchaseBillBL(); var list = bl.GetList(filters, sorts); return(list); }