Esempio n. 1
0
        public override void Refresh()
        {
            if (this.invoice == null)
            {
                this.invoice = new Book.Model.InvoiceHR();
                this.action  = "insert";
            }
            else
            {
                if (this.action != "insert")
                {
                    this.invoice = this.invoiceManager.Get(this.invoice.InvoiceId);
                    if (this.invoice == null)
                    {
                        this.invoice         = new Book.Model.InvoiceHR();
                        this.invoice.Details = new List <Model.InvoiceHRDetail>();
                        this.action          = "insert";
                    }
                }
            }
            this.textEditInvoiceId.EditValue  = this.invoice.InvoiceId;
            this.dateEditInvoiceDate.DateTime = this.invoice.InvoiceDate.Value;
            this.textEditNote.EditValue       = this.invoice.InvoiceNote;
            if (this.invoice.Customer != null)
            {
                this.lookUpEditCustomer.EditValue = this.invoice.Customer.CustomerId;
            }
            //this.buttonEditCompany.EditValue = this.invoice.Customer;
            this.buttonEditEmployee.EditValue = this.invoice.Employee0;
            this.lookUpEdit_Depot.EditValue   = this.invoice.DepotId;
            if (this.invoice.DepotId != null)
            {
                this.bindingSourceDepotPosition.DataSource = this.positionManager.Select(_depotManager.Get(invoice.DepotId));
            }

            this.EmpAudit.EditValue      = this.invoice.AuditEmp;
            this.textEditAuditState.Text = this.invoice.AuditStateName;

            this.bindingSourceInvoiceJCDetail.DataSource = this.invoice.Details;
            this.gridControl1.RefreshDataSource();
            switch (this.action)
            {
            case "insert":
            case "update":
                this.barButtonItem1.Enabled = true;
                break;

            case "view":
                this.barButtonItem1.Enabled = false;
                break;
            }

            base.Refresh();
            this.buttonEditEmployee.Enabled              = false;
            this.buttonEditEmployee.ButtonReadOnly       = true;
            this.lookUpEdit_Depot.Properties.ReadOnly    = true;
            this.lookUpEditCustomer.Properties.ReadOnly  = true;
            this.textEditFromInvoice.Properties.ReadOnly = true;
        }
Esempio n. 2
0
 protected override void AddNew()
 {
     this.invoice             = new Model.InvoiceHR();
     this.invoice.InvoiceDate = DateTime.Now;
     this.invoice.Details     = new List <Model.InvoiceHRDetail>();
     //this.invoice.Jcdetails = new List<Model.InvoiceJCDetail>();
     this.invoice.InvoiceId = this.invoiceManager.GetNewId();
 }
Esempio n. 3
0
 public ViewForm(Model.InvoiceHR initInvoiceHR)
     : this()
 {
     if (initInvoiceHR == null)
     {
         throw new ArithmeticException("initInvoiceHR");
     }
     this.invoice = initInvoiceHR;
 }
Esempio n. 4
0
 public ViewForm(string invoiceId)
     : this()
 {
     this.invoice = this.invoiceHRManager.Get(invoiceId);
     if (invoice == null)
     {
         throw new ArithmeticException("invoiceid");
     }
 }
Esempio n. 5
0
        protected override void MovePrev()
        {
            Model.InvoiceHR invoice = this.invoiceManager.GetPrev(this.invoice);
            if (invoice == null)
            {
                throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows);
            }

            this.invoice = this.invoiceManager.Get(invoice.InvoiceId);
        }
Esempio n. 6
0
 public EditForm(string invoiceId)
     : this()
 {
     this.invoice = this.invoiceManager.Get(invoiceId);
     if (invoice == null)
     {
         throw new ArithmeticException("invoiceid");
     }
     this.action = "update";
 }
Esempio n. 7
0
 public EditForm(Model.InvoiceHR invoice)
     : this()
 {
     if (invoice == null)
     {
         throw new ArithmeticException("invoiceid");
     }
     this.invoice = invoice;
     this.action  = "update";
 }
Esempio n. 8
0
        protected override Form GetViewForm()
        {
            Model.InvoiceHR invoice = this.SelectedItem as Model.InvoiceHR;
            if (invoice != null)
            {
                return(new ViewForm(invoice.InvoiceId));
            }

            return(null);
        }
Esempio n. 9
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();
            }
        }
Esempio n. 10
0
 public bool HasRowsBefore(Model.InvoiceHR e)
 {
     return(accessor.HasRowsBefore(e));
 }
Esempio n. 11
0
 public bool HasRowsAfter(Model.InvoiceHR e)
 {
     return(accessor.HasRowsAfter(e));
 }
Esempio n. 12
0
 public Model.InvoiceHR Get(string invoiceId)
 {
     Model.InvoiceHR invoice = accessor.Get(invoiceId);
     invoice.Details = invoiceHRDetailAccessor.Select(invoice);
     return(invoice);
 }
Esempio n. 13
0
 private void _TurnNull(Model.InvoiceHR invoice)
 {
     invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Null;
     _Update(invoice);
 }
Esempio n. 14
0
 public bool HasRowsBefore(Model.InvoiceHR e)
 {
     return(sqlmapper.QueryForObject <bool>("InvoiceHR.has_rows_before", e));
 }
Esempio n. 15
0
        private void _Update(Model.InvoiceHR invoice)
        {
            invoice.UpdateTime = DateTime.Now;;
            invoice.CustomerId = invoice.Customer.CustomerId;
            if (invoice.Employee0 != null)
            {
                invoice.Employee0Id = invoice.Employee0.EmployeeId;
            }

            Model.InvoiceHR 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:

                    accessor.Update(invoice);

                    invoiceHRDetailAccessor.Delete(invoice);

                    foreach (Model.InvoiceHRDetail detail in invoice.Details)
                    {
                        detail.InvoiceId = invoice.InvoiceId;
                        invoiceHRDetailAccessor.Insert(detail);
                    }
                    break;

                case Helper.InvoiceStatus.Normal:
                    accessor.Delete(invoiceOriginal.InvoiceId);
                    invoice.InsertTime = invoiceOriginal.InsertTime;
                    invoice.UpdateTime = DateTime.Now;
                    _Insert(invoice);

                    //accessor.Update(invoice);

                    //invoiceHZDetailAccessor.Delete(invoice);

                    //foreach (Model.InvoiceHZDetail detail in invoice.Details)
                    //{
                    //    stockAccessor.Increment(invoice.Depot, detail.Product, detail.InvoiceHZDetailQuantity.Value);

                    //    detail.InvoiceHZDetailId = Guid.NewGuid().ToString();
                    //    detail.InvoiceId = invoice.InvoiceId;

                    //    invoiceHZDetailAccessor.Insert(detail);
                    //}
                    //invoice.Employee2Id = invoice.Employee2.EmployeeId;
                    //invoice.InvoiceGZTime = DateTime.Now;
                    break;

                case Helper.InvoiceStatus.Null:
                    throw new InvalidOperationException();
                }
                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);
                    break;

                case Helper.InvoiceStatus.Null:
                    foreach (Model.InvoiceHRDetail detail in invoice.Details)
                    {
                        Model.Product p = detail.Product;
                        //if (detail.InvoiceProductUnit == p.ProductOuterPackagingUnit)
                        //{
                        //    quantity = detail.InvoiceHRDetailQuantity * p.ProductBaseUnitRelationship * p.ProductInnerUnitRelationship;
                        //}
                        //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit)
                        //{
                        //    quantity = detail.InvoiceHRDetailQuantity * p.ProductBaseUnitRelationship;
                        //}
                        //else
                        //{
                        //    quantity = detail.InvoiceHRDetailQuantity;
                        //}

                        //detail.Product.ProductCurrentJCQuantity += quantity;
                        p.StocksQuantity -= detail.InvoiceHRDetailQuantity;
                        productAccessor.Update(p);

                        stockAccessor.DecrementJR(new DepotPositionManager().Get(detail.DepotPositionId), p, detail.InvoiceHRDetailQuantity.Value);
                        Model.InvoiceJCDetail temp = invoiceJCDetailAccessor.Get(detail.InvoiceJCDetailId);
                        if (temp != null)
                        {
                            temp.InvoiceWeiHuaiRuQuantity += detail.InvoiceHRDetailQuantity;
                            temp.InvoiceYiHuaiRuQuantity  -= detail.InvoiceHRDetailQuantity;
                            invoiceJCDetailAccessor.Update(temp);
                        }
                    }
                    break;
                }
                break;

            case Helper.InvoiceStatus.Null:
                throw new InvalidOperationException();
            }
        }
Esempio n. 16
0
 public bool HasRowsAfter(Model.InvoiceHR e)
 {
     return(sqlmapper.QueryForObject <bool>("InvoiceHR.has_rows_after", e));
 }
Esempio n. 17
0
 public IList <Model.InvoiceJCDetail> Select(Model.InvoiceHR invoice)
 {
     return(accessor.Select(invoice));
 }
Esempio n. 18
0
 public Model.InvoiceHR GetNext(Model.InvoiceHR e)
 {
     return(sqlmapper.QueryForObject <Model.InvoiceHR>("InvoiceHR.get_next", e));
 }
Esempio n. 19
0
 public void Update(Model.InvoiceHR e)
 {
     this.Update <Model.InvoiceHR>(e);
 }
Esempio n. 20
0
 public Model.InvoiceHR GetPrev(Model.InvoiceHR e)
 {
     return(accessor.GetPrev(e));
 }
Esempio n. 21
0
 public Model.InvoiceHR GetPrev(Model.InvoiceHR e)
 {
     return(sqlmapper.QueryForObject <Model.InvoiceHR>("InvoiceHR.get_prev", e));
 }
Esempio n. 22
0
 protected override void MoveLast()
 {
     this.invoice = this.invoiceManager.Get(this.invoiceManager.GetLast() == null ? "" : this.invoiceManager.GetLast().InvoiceId);
 }
Esempio n. 23
0
 public Model.InvoiceHR GetNext(Model.InvoiceHR e)
 {
     return(accessor.GetNext(e));
 }
Esempio n. 24
0
 public void Insert(Model.InvoiceHR e)
 {
     this.Insert <Model.InvoiceHR>(e);
 }