Exemple #1
0
        protected override void AddNew()
        {
            this.invoice = new Model.InvoiceFT();

            this.invoice.InvoiceId   = this.invoiceManager.GetNewId();
            this.invoice.InvoiceDate = DateTime.Now;
        }
        public void Validate(Model.InvoiceFT invoice)
        {
            if (invoice.Account1 == null)
            {
                throw new Helper.RequireValueException("Account1");
            }

            if (invoice.Account2 == null)
            {
                throw new Helper.RequireValueException("Account2");
            }

            if (invoice.Employee0 == null)
            {
                throw new Helper.RequireValueException("Employee0");
            }

            if (string.IsNullOrEmpty(invoice.InvoiceId))
            {
                throw new Helper.RequireValueException("Id");
            }

            if (invoice.InvoiceTotal == null)
            {
                throw new Helper.RequireValueException("Total");
            }
        }
        private void _Insert(Model.InvoiceFT invoice)
        {
            _ValidateForInsert(invoice);
            invoice.Account1Id  = invoice.Account1.AccountId;
            invoice.Account2Id  = invoice.Account2.AccountId;
            invoice.Employee0Id = invoice.Employee0.EmployeeId;

            invoice.Employee1Id = invoice.Employee1.EmployeeId;

            if (invoice.InvoiceStatus == (int)Helper.InvoiceStatus.Normal)
            {
                invoice.Employee2Id   = invoice.Employee2.EmployeeId;
                invoice.InvoiceGZTime = DateTime.Now;
            }

            accessor.Insert(invoice);

            if (invoice.InvoiceStatus == (int)Helper.InvoiceStatus.Normal)
            {
                Model.Account account1 = invoice.Account1;
                Model.Account account2 = invoice.Account2;
                account1.AccountBalance1 -= invoice.InvoiceTotal;
                account2.AccountBalance1 += invoice.InvoiceTotal;

                accountAccessor.Update(account1);
                accountAccessor.Update(account2);
            }
        }
Exemple #4
0
 public ViewForm(Model.InvoiceFT invoiceFT) : this()
 {
     if (invoiceFT == null)
     {
         throw new ArgumentNullException("invoiceFT");
     }
     this.invoice = invoiceFT;
 }
Exemple #5
0
 protected override void MoveLast()
 {
     if (LastFlag == 1)
     {
         LastFlag = 0; return;
     }
     this.invoice = this.invoiceManager.Get(this.invoiceManager.GetLast() == null ? "" : this.invoiceManager.GetLast().InvoiceId);
 }
Exemple #6
0
 public ViewForm(string invoiceId)
     : this()
 {
     this.invoice = this.invoiceFTManager.Get(invoiceId);
     if (this.invoice == null)
     {
         throw new ArgumentNullException("invoiceId");
     }
 }
Exemple #7
0
        protected override Form GetViewForm()
        {
            Model.InvoiceFT invoice = this.SelectedItem as Model.InvoiceFT;
            if (invoice != null)
            {
                return(new EditForm(invoice.InvoiceId));
            }

            return(null);
        }
Exemple #8
0
        protected override void MovePrev()
        {
            Model.InvoiceFT invoice = this.invoiceManager.GetPrev(this.invoice);
            if (invoice == null)
            {
                throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows);
            }

            this.invoice = this.invoiceManager.Get(invoice.InvoiceId);
        }
Exemple #9
0
        public R01(string invoiceId)
        {
            InitializeComponent();

            this.invoice = this.invoiceManager.Get(invoiceId);

            if (this.invoice == null)
            {
                return;
            }
        }
Exemple #10
0
 public EditForm(Model.InvoiceFT invoiceFT) : this()
 {
     if (invoiceFT == null)
     {
         throw new ArithmeticException("invoiceid");
     }
     this.invoice = invoiceFT;
     this.action  = "view";
     if (this.action == "view")
     {
         LastFlag = 1;
     }
 }
Exemple #11
0
 public EditForm(string invoiceId)
     : this()
 {
     this.invoice = this.invoiceManager.Get(invoiceId);
     if (this.invoice == null)
     {
         throw new ArithmeticException("invoiceid");
     }
     this.action = "view";
     if (this.action == "view")
     {
         LastFlag = 1;
     }
 }
Exemple #12
0
        protected override void TurnNull()
        {
            if (this.invoice == null)
            {
                return;
            }
            if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }

            this.invoiceManager.TurnNull(this.invoice.InvoiceId);
            this.invoice = this.invoiceManager.GetNext(this.invoice);
            if (this.invoice == null)
            {
                this.invoice = this.invoiceManager.GetLast();
            }
        }
Exemple #13
0
 public void Update(Model.InvoiceFT e)
 {
     this.Update <Model.InvoiceFT>(e);
 }
Exemple #14
0
 public void Insert(Model.InvoiceFT e)
 {
     this.Insert <Model.InvoiceFT>(e);
 }
Exemple #15
0
 public Model.InvoiceFT GetNext(Model.InvoiceFT e)
 {
     return(accessor.GetNext(e));
 }
Exemple #16
0
 public Model.InvoiceFT GetPrev(Model.InvoiceFT e)
 {
     return(accessor.GetPrev(e));
 }
Exemple #17
0
 public Model.InvoiceFT GetNext(Model.InvoiceFT e)
 {
     return(sqlmapper.QueryForObject <Model.InvoiceFT>("InvoiceFT.get_next", e));
 }
Exemple #18
0
 private void _TurnNormal(Model.InvoiceFT invoice)
 {
     invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Normal;
     _Update(invoice);
 }
Exemple #19
0
        private void _Update(Model.InvoiceFT invoice)
        {
            _ValidateForUpdate(invoice);

            invoice.UpdateTime  = DateTime.Now;
            invoice.Account1Id  = invoice.Account1.AccountId;
            invoice.Account2Id  = invoice.Account2.AccountId;
            invoice.Employee0Id = invoice.Employee0.EmployeeId;

            Model.InvoiceFT invoiceOriginal = this.Get(invoice.InvoiceId);

            Helper.InvoiceStatus invoiceStatus = (Helper.InvoiceStatus)invoice.InvoiceStatus.Value;

            switch ((Helper.InvoiceStatus)invoiceOriginal.InvoiceStatus)
            {
            case Helper.InvoiceStatus.Draft:
                switch (invoiceStatus)
                {
                case Helper.InvoiceStatus.Draft:
                    break;

                case Helper.InvoiceStatus.Normal:
                    accessor.Delete(invoiceOriginal.InvoiceId);
                    invoice.InsertTime = invoiceOriginal.InsertTime;
                    invoice.UpdateTime = DateTime.Now;
                    _Insert(invoice);
                    //invoice.Employee2Id = invoice.Employee2.EmployeeId;
                    //invoice.InvoiceGZTime = DateTime.Now;
                    //accessor.Update(invoice);

                    //Model.Account account1 = invoice.Account1;
                    //Model.Account account2 = invoice.Account2;
                    //account1.AccountBalance1 -= invoice.InvoiceTotal;
                    //account2.AccountBalance1 += invoice.InvoiceTotal;

                    //accountAccessor.Update(account1);
                    //accountAccessor.Update(account2);


                    break;

                case Helper.InvoiceStatus.Null:
                    throw new InvalidOperationException();

                default:
                    break;
                }
                break;

            case Helper.InvoiceStatus.Normal:
                switch (invoiceStatus)
                {
                case Helper.InvoiceStatus.Draft:
                    throw new InvalidOperationException();

                case Helper.InvoiceStatus.Normal:
                    invoiceOriginal.InvoiceStatus = (int)Helper.InvoiceStatus.Null;
                    _TurnNull(invoiceOriginal);
                    accessor.Delete(invoiceOriginal.InvoiceId);
                    invoice.InsertTime = invoiceOriginal.InsertTime;
                    invoice.UpdateTime = DateTime.Now;
                    _Insert(invoice);
                    //invoice.Employee2Id = invoice.Employee2.EmployeeId;
                    //accessor.Update(invoice);

                    //Model.Account account1 = invoice.Account1;
                    //Model.Account account2 = invoice.Account2;

                    //account1.AccountBalance1 += invoiceOriginal.InvoiceTotal;
                    //account1.AccountBalance1 -= invoice.InvoiceTotal;

                    //account2.AccountBalance1 -= invoiceOriginal.InvoiceTotal;
                    //account2.AccountBalance1 += invoice.InvoiceTotal;

                    //accountAccessor.Update(account1);
                    //accountAccessor.Update(account2);


                    break;

                case Helper.InvoiceStatus.Null:
                    //invoice.Employee3Id = V.ActiveEmployee.EmployeeId;
                    //invoice.InvoiceZFTime = DateTime.Now;
                    //invoice.InvoiceZFCause = "";

                    //accessor.Update(invoice);

                    //消除影响

                    Model.Account acc1 = invoice.Account1;
                    Model.Account acc2 = invoice.Account2;
                    acc1.AccountBalance1 += invoice.InvoiceTotal;
                    acc2.AccountBalance1 -= invoice.InvoiceTotal;

                    accountAccessor.Update(acc1);
                    accountAccessor.Update(acc2);
                    break;
                }
                break;

            case Helper.InvoiceStatus.Null:
                throw new InvalidOperationException();
            }
        }
Exemple #20
0
        public override void Refresh()
        {
            if (this.invoice == null)
            {
                this.invoice = new Book.Model.InvoiceFT();
                this.action  = "insert";
            }
            else
            {
                if (this.action == "view")
                {
                    this.invoice = this.invoiceManager.Get(invoice.InvoiceId);
                }
            }
            this.textEditInvoiceId.EditValue  = this.invoice.InvoiceId;
            this.dateEditInvoiceDate.DateTime = this.invoice.InvoiceDate.Value;

            this.buttonEditEmployee.EditValue = this.invoice.Employee0;
            this.buttonEditAccount1.EditValue = this.invoice.Account1;
            this.buttonEditAccount2.EditValue = this.invoice.Account2;

            //this.textEditAbstract.EditValue = this.invoice.InvoiceAbstract;
            this.textEditNote.EditValue = this.invoice.InvoiceNote;

            this.calcEditTotal.EditValue = this.invoice.InvoiceTotal;


            switch (this.action)
            {
            case "insert":
                this.textEditInvoiceId.Properties.ReadOnly             = false;
                this.dateEditInvoiceDate.Properties.ReadOnly           = false;
                this.dateEditInvoiceDate.Properties.Buttons[0].Visible = true;

                this.calcEditTotal.Properties.ReadOnly = false;

                //this.textEditAbstract.Properties.ReadOnly = false;
                this.textEditNote.Properties.ReadOnly = false;

                this.buttonEditAccount1.ShowButton = true;
                this.buttonEditAccount2.ShowButton = true;
                this.buttonEditEmployee.ShowButton = true;

                this.buttonEditAccount1.ButtonReadOnly = false;
                this.buttonEditAccount2.ButtonReadOnly = false;
                this.buttonEditEmployee.ButtonReadOnly = false;
                break;

            case "update":
                this.textEditInvoiceId.Properties.ReadOnly             = true;
                this.dateEditInvoiceDate.Properties.ReadOnly           = true;
                this.dateEditInvoiceDate.Properties.Buttons[0].Visible = false;

                this.calcEditTotal.Properties.ReadOnly = false;

                //this.textEditAbstract.Properties.ReadOnly = false;
                this.textEditNote.Properties.ReadOnly = false;

                this.buttonEditAccount1.ShowButton = true;
                this.buttonEditAccount2.ShowButton = true;
                this.buttonEditEmployee.ShowButton = true;

                this.buttonEditAccount1.ButtonReadOnly = false;
                this.buttonEditAccount2.ButtonReadOnly = false;
                this.buttonEditEmployee.ButtonReadOnly = false;

                break;

            case "view":
                this.textEditInvoiceId.Properties.ReadOnly             = true;
                this.dateEditInvoiceDate.Properties.ReadOnly           = true;
                this.dateEditInvoiceDate.Properties.Buttons[0].Visible = false;

                this.calcEditTotal.Properties.ReadOnly = true;

                //this.textEditAbstract.Properties.ReadOnly = true;
                this.textEditNote.Properties.ReadOnly = true;

                this.buttonEditAccount1.ShowButton = false;
                this.buttonEditAccount2.ShowButton = false;
                this.buttonEditEmployee.ShowButton = false;

                this.buttonEditAccount1.ButtonReadOnly = true;
                this.buttonEditAccount2.ButtonReadOnly = true;
                this.buttonEditEmployee.ButtonReadOnly = true;
                break;

            default:
                break;
            }
            base.Refresh();
        }
Exemple #21
0
 public bool HasRowsBefore(Model.InvoiceFT e)
 {
     return(sqlmapper.QueryForObject <bool>("InvoiceFT.has_rows_before", e));
 }
Exemple #22
0
 public bool HasRowsBefore(Model.InvoiceFT e)
 {
     return(accessor.HasRowsBefore(e));
 }
Exemple #23
0
 public bool HasRowsAfter(Model.InvoiceFT e)
 {
     return(sqlmapper.QueryForObject <bool>("InvoiceFT.has_rows_after", e));
 }
Exemple #24
0
 public bool HasRowsAfter(Model.InvoiceFT e)
 {
     return(accessor.HasRowsAfter(e));
 }
Exemple #25
0
 public Model.InvoiceFT GetPrev(Model.InvoiceFT e)
 {
     return(sqlmapper.QueryForObject <Model.InvoiceFT>("InvoiceFT.get_prev", e));
 }
Exemple #26
0
 protected override void MoveFirst()
 {
     this.invoice = this.invoiceManager.Get(this.invoiceManager.GetFirst() == null ? "" : this.invoiceManager.GetFirst().InvoiceId);
 }