private void Validate(Model.BillIdSet billIdSet) { if (string.IsNullOrEmpty(billIdSet.EnglishId)) { throw new Helper.InvalidValueException(Model.BillIdSet.PRO_EnglishId); } if (string.IsNullOrEmpty(billIdSet.StartBillId)) { throw new Helper.InvalidValueException(Model.BillIdSet.PRO_StartBillId); } if (string.IsNullOrEmpty(billIdSet.EndBillId)) { throw new Helper.InvalidValueException(Model.BillIdSet.PRO_EndBillId); } if (billIdSet.StartDate == null) { throw new Helper.InvalidValueException(Model.BillIdSet.PRO_StartDate); } if (billIdSet.EndDate == null) { throw new Helper.InvalidValueException(Model.BillIdSet.PRO_EndDate); } if (billIdSet.EnglishId.Length != 2) { throw new Helper.RequireValueException(Model.BillIdSet.PRO_EnglishId + "2"); } if (Convert.ToInt32(billIdSet.EndBillId) - Convert.ToInt32(billIdSet.StartBillId) <= 0) { throw new Helper.RequireValueException(Model.BillIdSet.PRO_EndBillId + "2"); } }
/// <summary> /// 生成發票編號 /// </summary> private void GenerateBillId() { Model.BillIdSet billIdSet = this.BillIdSetManager.SelectEnable(); if (billIdSet != null) { if (DateTime.Now.Date > billIdSet.EndDate.Value.Date || DateTime.Now.Date < billIdSet.StartDate.Value.Date) { //throw new Helper.MessageValueException("當前日期已超出編號使用日期!"); MessageBox.Show("當前日期已超出發票編號使用日期!", this.Text, MessageBoxButtons.OK); return; } //this._acInvoiceXoBill.Id = this.BillIdDeletedManager.SelectBillIdByBillIdSetId(billIdSet.BillIdSetId); //this.billIdIsDeleted = 1; //发票编号不能回收 //if (string.IsNullOrEmpty(this._acInvoiceXoBill.Id)) //{ // this.billIdIsDeleted = 0; int id = Convert.ToInt32(billIdSet.StartBillId) + (billIdSet.IdNumber.HasValue ? billIdSet.IdNumber.Value : 0); if (id > Convert.ToInt32(billIdSet.EndBillId)) { //throw new Helper.MessageValueException("發票編號已超出編號使用範圍!"); MessageBox.Show("發票編號已超出編號使用範圍!", this.Text, MessageBoxButtons.OK); return; } this._acInvoiceXoBill.Id = billIdSet.EnglishId + id.ToString("00000000"); //发票采用八位编码,如1显示为00000001 //} } else { //throw new Helper.MessageValueException("請先設置發票編碼!"); MessageBox.Show("請先設置發票編碼!", this.Text, MessageBoxButtons.OK); return; } }
/// <summary> /// Insert a BillIdSet. /// </summary> public void Insert(Model.BillIdSet billIdSet) { // // todo:add other logic here // try { BL.V.BeginTransaction(); this.Validate(billIdSet); billIdSet.InsertTime = DateTime.Now; billIdSet.UpdatetTime = DateTime.Now; //如果这个编号启用,则其他所有失效 if (billIdSet.IdState.HasValue && billIdSet.IdState.Value) { this.DisableAll(); } accessor.Insert(billIdSet); BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
protected override void MoveNext() { Model.BillIdSet p = this.manager.GetNext(this._billIdSet); if (p == null) { throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows); } this._billIdSet = p; }
protected override void AddNew() { this._billIdSet = new Book.Model.BillIdSet(); this._billIdSet.BillIdSetId = Guid.NewGuid().ToString(); this._billIdSet.IdState = true; this._billIdSet.IdNumber = 0; this.action = "insert"; }
private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { if (this.bindingSource1.Current != null) { Model.BillIdSet model = this.bindingSource1.Current as Model.BillIdSet; if (model != null) { this._billIdSet = model; this.action = "view"; this.Refresh(); } } }
public override void Refresh() { if (this._billIdSet == null) { this.AddNew(); } else { if (this.action == "view") { this._billIdSet = this.manager.Get(this._billIdSet.BillIdSetId); } } this.txt_EnglishId.Text = this._billIdSet.EnglishId; this.txt_StartBillId.Text = this._billIdSet.StartBillId; this.txt_EndBillId.Text = this._billIdSet.EndBillId; this.date_StartDate.EditValue = this._billIdSet.StartDate; this.date_EndDate.EditValue = this._billIdSet.EndDate; this.checkEditIdState.Checked = this._billIdSet.IdState.HasValue ? this._billIdSet.IdState.Value : false; this.bindingSource1.DataSource = this.ListBillIdSet = this.manager.SelectAll(); base.Refresh(); //不能删除,防止发生一些编号生成错误 this.CannotDelete(); switch (this.action) { case "view": this.gridView1.OptionsBehavior.Editable = false; this.txt_EndBillId.Enabled = true; this.txt_EnglishId.Enabled = true; this.txt_StartBillId.Enabled = true; break; case "insert": this.gridView1.OptionsBehavior.Editable = false; this.txt_EndBillId.Enabled = true; this.txt_EnglishId.Enabled = true; this.txt_StartBillId.Enabled = true; break; case "update": this.gridView1.OptionsBehavior.Editable = false; this.txt_EndBillId.Enabled = false; this.txt_EnglishId.Enabled = false; this.txt_StartBillId.Enabled = false; break; } }
protected override void Delete() { if (this._billIdSet == null) { return; } if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Model.BillIdSet model = this.manager.GetNext(this._billIdSet); this.manager.Delete(this._billIdSet.BillIdSetId); if (model == null) { this._billIdSet = this.manager.GetLast(); } else { this._billIdSet = model; } } }
public Model.BillIdSet GetPrev(Model.BillIdSet e) { return(accessor.GetPrev(e)); }
protected override void MoveLast() { this._billIdSet = this.manager.GetLast(); }
public void Insert(Model.BillIdSet e) { this.Insert <Model.BillIdSet>(e); }
public bool HasRowsBefore(Model.BillIdSet e) { return(accessor.HasRowsBefore(e)); }
public bool HasRowsAfter(Model.BillIdSet e) { return(accessor.HasRowsAfter(e)); }
public Model.BillIdSet GetPrev(Model.BillIdSet e) { return(sqlmapper.QueryForObject <Model.BillIdSet>("BillIdSet.get_prev", e)); }
public Model.BillIdSet GetNext(Model.BillIdSet e) { return(sqlmapper.QueryForObject <Model.BillIdSet>("BillIdSet.get_next", e)); }
public bool HasRowsAfter(Model.BillIdSet e) { return(sqlmapper.QueryForObject <bool>("BillIdSet.has_rows_after", e)); }
public bool HasRowsBefore(Model.BillIdSet e) { return(sqlmapper.QueryForObject <bool>("BillIdSet.has_rows_before", e)); }
public void Update(Model.BillIdSet e) { this.Update <Model.BillIdSet>(e); }
public void UpdateIdnumber(Model.BillIdSet billIdSet) { accessor.Update(billIdSet); }
public Model.BillIdSet GetNext(Model.BillIdSet e) { return(accessor.GetNext(e)); }