コード例 #1
0
ファイル: R01.cs プロジェクト: daobataotie/EDERP
        public R01(string invoiceId)
        {
            InitializeComponent();

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

            if (this.invoice == null)
            {
                return;
            }

            this.invoice.Details = this.invoiceDetailManager.Select(this.invoice);

            this.DataSource = this.invoice.Details;

            //CompanyInfo
            this.xrLabelCompanyInfoAddress.Text  = BL.Settings.CompanyAddress1;
            this.xrLabelCompanyInfoFAX.Text      = BL.Settings.CompanyFax;
            this.xrLabelCompanyInfoName.Text     = BL.Settings.CompanyChineseName + Properties.Resources.InvoiceZS;
            this.xrLabelCompanyInfoTelphone.Text = BL.Settings.CompanyPhone;

            //每页合计统计
            this.xrLabelPageTotal.Summary.Running          = SummaryRunning.Page;
            this.xrLabelPageTotal.Summary.Func             = SummaryFunc.Sum;
            this.xrLabelPageTotal.Summary.FormatString     = "{0:0}";
            this.xrLabelPageTotal.Summary.IgnoreNullValues = true;
            this.xrLabelPageTotal.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEZSDETAILMONEY, "{0:0}");

            //客户信息
            this.xrLabelCustomName.Text     = this.invoice.Customer.CustomerShortName;
            this.xrLabelCustomFax.Text      = this.invoice.Customer.CustomerFax;
            this.xrLabelCustomTel.Text      = string.IsNullOrEmpty(this.invoice.Customer.CustomerPhone) ? this.invoice.Customer.CustomerPhone1 : this.invoice.Customer.CustomerPhone;
            this.xrLabelTongYiNo.Text       = this.invoice.Customer.CustomerNumber;
            this.xrLabelSongHuoAddress.Text = this.invoice.Customer.CustomerJinChuAddress;

            //单据信息
            this.xrLabelInvoiceDate.Text = this.invoice.InvoiceDate.Value.ToString("yyyy-MM-dd");
            this.xrLabelInvoiceId.Text   = this.invoice.InvoiceId;
            this.xrLabelYeWuName.Text    = this.invoice.Employee0.EmployeeName;
            this.xrLabelNote.Text        = this.invoice.InvoiceNote;

            this.xrLabelReportTotal.Summary.Func             = SummaryFunc.Sum;
            this.xrLabelReportTotal.Summary.IgnoreNullValues = true;
            this.xrLabelReportTotal.Summary.Running          = SummaryRunning.Report;
            this.xrLabelReportTotal.Summary.FormatString     = "{0:0}";
            this.xrLabelReportTotal.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEZSDETAILMONEY, "{0:0}");

            this.xrLabelNote.Text = this.invoice.InvoiceNote;

            //明细信息
            this.xrTableCellProductId.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_Id);
            this.xrTableCellProductName.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_ProductName);
            this.xrTableCellProductGuige.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_ProductSpecification);
            this.xrTableCellProductUnit.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEPRODUCTUNIT);
            this.xrTableCellQuantity.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEZSDETAILQUANTITY);
            this.xrTableCellUintPrice.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEZSDETAILPRICE, "{0:0}");
            this.xrTableCellMoney.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEZSDETAILMONEY, "{0:0}");
            this.xrTableDetailNote.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEZSDETAILNOTE);
        }
コード例 #2
0
ファイル: ViewForm.cs プロジェクト: daobataotie/EDERP
 public ViewForm(string invoiceId)
     : this()
 {
     this.invoice = invoiceZSManager.Get(invoiceId);
     if (this.invoice == null)
     {
         throw new ArithmeticException("invoiceZSManager");
     }
 }
コード例 #3
0
        protected override void MovePrev()
        {
            Model.InvoiceZS invoice = this.invoiceManager.GetPrev(this.invoice);
            if (invoice == null)
            {
                throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows);
            }

            this.invoice = this.invoiceManager.Get(invoice.InvoiceId);
        }
コード例 #4
0
 public EditForm(Model.InvoiceZS invoicezs)
     : this()
 {
     if (invoicezs == null)
     {
         throw new ArithmeticException("invoiceid");
     }
     this.invoice = invoicezs;
     this.action  = "update";
 }
コード例 #5
0
ファイル: ListForm.cs プロジェクト: daobataotie/EDERP
        protected override Form GetViewForm()
        {
            Model.InvoiceZS invoice = this.SelectedItem as Model.InvoiceZS;
            if (invoice != null)
            {
                return(new ViewForm(invoice.InvoiceId));
            }

            return(null);
        }
コード例 #6
0
 public EditForm(string invoiceId)
     : this()
 {
     this.invoice = invoiceManager.Get(invoiceId);
     if (this.invoice == null)
     {
         throw new ArithmeticException("invoiceid");
     }
     this.action = "update";
 }
コード例 #7
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();
            }
        }
コード例 #8
0
        private void Validate(Model.InvoiceZS invoice)
        {
            if (string.IsNullOrEmpty(invoice.InvoiceId))
            {
                throw new Helper.RequireValueException("Id");
            }

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

            //if (invoice.Employee1 == null)
            //  throw new Helper.RequireValueException("Employee1");

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

            //if (invoice.Depot == null)
            //    throw new Helper.RequireValueException("Depot");

            if (invoice.Details.Count == 0)
            {
                throw new Helper.RequireValueException("Details");
            }

            foreach (Model.InvoiceZSDetail detail in invoice.Details)
            {
                if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId))
                {
                    continue;
                }
                if (detail.InvoiceZSDetailQuantity == 0)
                {
                    throw new Helper.RequireValueException("Details");
                }
            }
        }
コード例 #9
0
        protected override void AddNew()
        {
            this.bindingSource3.DataSource = null;
            this.invoice             = new Model.InvoiceZS();
            this.invoice.InvoiceId   = this.invoiceManager.GetNewId();
            this.invoice.InvoiceDate = DateTime.Now;
            this.invoice.Details     = new List <Model.InvoiceZSDetail>();


            if (this.action == "insert")
            {
                Model.InvoiceZSDetail detail = new Model.InvoiceZSDetail();
                detail.InvoiceZSDetailId       = Guid.NewGuid().ToString();
                detail.InvoiceZSDetailMoney    = 0;
                detail.InvoiceZSDetailNote     = "";
                detail.InvoiceZSDetailPrice    = 0;
                detail.InvoiceZSDetailQuantity = 0;
                detail.InvoiceProductUnit      = "";
                detail.PrimaryKey = new Book.Model.CustomerProducts();
                this.invoice.Details.Add(detail);
                this.bindingSource1.Position = this.bindingSource1.IndexOf(detail);
            }
        }
コード例 #10
0
 public Model.InvoiceZS GetPrev(Model.InvoiceZS e)
 {
     return(accessor.GetPrev(e));
 }
コード例 #11
0
 public bool HasRowsAfter(Model.InvoiceZS e)
 {
     return(accessor.HasRowsAfter(e));
 }
コード例 #12
0
 public bool HasRowsBefore(Model.InvoiceZS e)
 {
     return(accessor.HasRowsBefore(e));
 }
コード例 #13
0
        private void _Insert(Model.InvoiceZS invoice)
        {
            _ValidateForInsert(invoice);
            //客户
            if (invoice.Customer != null)
            {
                invoice.CustomerId = invoice.Customer.CustomerId;
            }
            // 库房
            //invoice.DepotId = invoice.Depot.DepotId;
            //经手人
            if (invoice.Employee0 != null)
            {
                invoice.Employee0Id = invoice.Employee0.EmployeeId;
            }
            //录单人
            if (invoice.Employee1 != null)
            {
                invoice.Employee1Id = invoice.Employee1.EmployeeId;
            }

            if ((Helper.InvoiceStatus)invoice.InvoiceStatus.Value == Helper.InvoiceStatus.Normal)
            {
                //过账人
                if (invoice.Employee2 != null)
                {
                    invoice.Employee2Id = invoice.Employee2.EmployeeId;
                }
                //过账时间
                invoice.InvoiceGZTime = DateTime.Now;
            }
            //插入表单
            accessor.Insert(invoice);

            //插入明细
            foreach (Model.InvoiceZSDetail detail in invoice.Details)
            {
                if (detail.PrimaryKey == null || string.IsNullOrEmpty(detail.PrimaryKey.PrimaryKeyId))
                {
                    throw new Exception("商品不為空");
                }
                if (detail.DepotPosition == null || detail.DepotPositionId == null)
                {
                    throw new Exception("貨位不為空");
                }

                detail.InvoiceId = invoice.InvoiceId;
                invoiceZSDetailAccessor.Insert(detail);

                Model.CustomerProducts p = detail.PrimaryKey;
                p.PrimaryKeyId = detail.PrimaryKey.PrimaryKeyId;
                if (p.DepotQuantity == null)
                {
                    p.DepotQuantity = 0;
                }
                if (p.OrderQuantity == null)
                {
                    p.OrderQuantity = 0;
                }
                p.DepotQuantity -= detail.InvoiceZSDetailQuantity;
                //更新产品表库存
                customerProductsAccessor.Update(p);
            }
        }
コード例 #14
0
 public Model.InvoiceZS Get(string invoiceId)
 {
     Model.InvoiceZS invoice = accessor.Get(invoiceId);
     invoice.Details = invoiceZSDetailAccessor.Select(invoice);
     return(invoice);
 }
コード例 #15
0
 public bool HasRowsBefore(Model.InvoiceZS e)
 {
     return(sqlmapper.QueryForObject <bool>("InvoiceZS.has_rows_before", e));
 }
コード例 #16
0
 public void Insert(Model.InvoiceZS e)
 {
     this.Insert <Model.InvoiceZS>(e);
 }
コード例 #17
0
        private void _Update(Model.InvoiceZS invoice)
        {
            _ValidateForUpdate(invoice);

            invoice.UpdateTime = DateTime.Now;
            //invoice.DepotId = invoice.Depot.DepotId;
            invoice.Employee0Id = invoice.Employee0.EmployeeId;
            invoice.CustomerId  = invoice.Customer.CustomerId;

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

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

            switch ((Helper.InvoiceStatus)invoiceOriginal.InvoiceStatus)
            {
            case Helper.InvoiceStatus.Draft:
                switch ((Helper.InvoiceStatus)invoice.InvoiceStatus)
                {
                case Helper.InvoiceStatus.Draft:

                    invoiceZSDetailAccessor.Delete(invoice);

                    foreach (Model.InvoiceZSDetail detail in invoice.Details)
                    {
                        if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId))
                        {
                            continue;
                        }
                        detail.InvoiceZSDetailId = Guid.NewGuid().ToString();
                        detail.InvoiceId         = invoice.InvoiceId;
                        invoiceZSDetailAccessor.Insert(detail);
                    }
                    break;

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

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

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

                case Helper.InvoiceStatus.Normal:
                    invoiceOriginal.InvoiceStatus = (int)Helper.InvoiceStatus.Null;
                    _TurnNull(invoiceOriginal);
                    invoiceZSDetailAccessor.Delete(invoiceOriginal);
                    accessor.Delete(invoiceOriginal.InvoiceId);
                    invoice.InsertTime = invoiceOriginal.InsertTime;
                    invoice.UpdateTime = DateTime.Now;

                    _Insert(invoice);
                    ////消除影响
                    //foreach (Model.InvoiceZSDetail detail in invoiceOriginal.Details)
                    //{
                    //    stockAccessor.Increment(invoiceOriginal.Depot, detail.Product, detail.InvoiceZSDetailQuantity.Value);
                    //}
                    //accessor.Delete(invoiceOriginal.InvoiceId);

                    //invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Normal;
                    //invoice.InsertTime = invoiceOriginal.InsertTime;
                    //invoice.UpdateTime = DateTime.Now;

                    //_Insert(invoice);
                    break;

                case Helper.InvoiceStatus.Null:

                    //invoice.Employee3Id = V.ActiveEmployee.EmployeeId;
                    //invoice.InvoiceZFTime = DateTime.Now;
                    //invoice.InvoiceZFCause = "";

                    //accessor.Update(invoice);

                    //invoice.Details = invoiceZSDetailAccessor.Select(invoice);

                    //消除影响
                    foreach (Model.InvoiceZSDetail detail in invoice.Details)
                    {
                        //if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) continue;

                        Model.CustomerProducts p = detail.PrimaryKey;
                        p.PrimaryKeyId = detail.PrimaryKey.PrimaryKeyId;
                        if (p.DepotQuantity == null)
                        {
                            p.DepotQuantity = 0;
                        }
                        if (p.OrderQuantity == null)
                        {
                            p.OrderQuantity = 0;
                        }
                        p.DepotQuantity += detail.InvoiceZSDetailQuantity;
                        customerProductsAccessor.Update(p);
                    }
                    break;
                }
                break;

            case Helper.InvoiceStatus.Null:
                throw new InvalidOperationException();
            }
        }
コード例 #18
0
 private void _TurnNormal(Model.InvoiceZS invoice)
 {
     invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Normal;
     _Update(invoice);
 }
コード例 #19
0
 public Model.InvoiceZS GetNext(Model.InvoiceZS e)
 {
     return(accessor.GetNext(e));
 }
コード例 #20
0
 public IList <Book.Model.InvoiceZSDetail> Select(Model.InvoiceZS invoice)
 {
     return(accessor.Select(invoice));
 }
コード例 #21
0
 public Model.InvoiceZS GetNext(Model.InvoiceZS e)
 {
     return(sqlmapper.QueryForObject <Model.InvoiceZS>("InvoiceZS.get_next", e));
 }
コード例 #22
0
 public void Update(Model.InvoiceZS e)
 {
     this.Update <Model.InvoiceZS>(e);
 }
コード例 #23
0
 protected override void MoveLast()
 {
     this.invoice = this.invoiceManager.Get(this.invoiceManager.GetLast() == null ? "" : this.invoiceManager.GetLast().InvoiceId);
 }
コード例 #24
0
 public bool HasRowsAfter(Model.InvoiceZS e)
 {
     return(sqlmapper.QueryForObject <bool>("InvoiceZS.has_rows_after", e));
 }
コード例 #25
0
        public override void Refresh()
        {
            if (this.invoice == null)
            {
                this.invoice = new Book.Model.InvoiceZS();
                this.action  = "insert";
            }

            if (this.action == "view")
            {
                this.invoice = this.invoiceManager.Get(invoice.InvoiceId);
            }

            if (invoice.Depot != null)
            {
                this.bindingSource3.DataSource = this.depotPositionManager.Select(invoice.Depot);
            }
            this.textEditInvoiceId.EditValue  = this.invoice.InvoiceId;
            this.dateEditInvoiceDate.DateTime = this.invoice.InvoiceDate.Value;
            this.textEditNote.EditValue       = this.invoice.InvoiceNote;
            this.buttonEditDepot.EditValue    = this.invoice.Depot;
            this.buttonEditCompany.EditValue  = this.invoice.Customer;
            this.buttonEditEmployee.EditValue = this.invoice.Employee0;
            this.buttonEditDepot.EditValue    = this.invoice.Depot;
            this.calcEditTotal.EditValue      = this.invoice.InvoiceTotal;
            this.bindingSource1.DataSource    = this.invoice.Details;
            this.EmpAudit.EditValue           = this.invoice.AuditEmp;
            this.textEditAuditState.Text      = this.invoice.AuditStateName;

            this.bindingSource2.DataSource = this.customerProductManager.Select(this.buttonEditCompany.EditValue as Model.Customer);

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

                this.buttonEditCompany.ButtonReadOnly  = false;
                this.buttonEditEmployee.ButtonReadOnly = false;
                this.buttonEditDepot.ButtonReadOnly    = false;

                this.buttonEditCompany.ShowButton  = true;
                this.buttonEditEmployee.ShowButton = true;
                this.buttonEditDepot.ShowButton    = true;

                this.simpleButtonAppend.Enabled         = true;
                this.simpleButtonRemove.Enabled         = true;
                this.gridView1.OptionsBehavior.Editable = true;
                break;

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

                this.buttonEditCompany.ButtonReadOnly  = false;
                this.buttonEditEmployee.ButtonReadOnly = false;
                this.buttonEditDepot.ButtonReadOnly    = false;

                this.buttonEditCompany.ShowButton  = true;
                this.buttonEditEmployee.ShowButton = true;
                this.buttonEditDepot.ShowButton    = true;

                this.simpleButtonAppend.Enabled         = true;
                this.simpleButtonRemove.Enabled         = true;
                this.gridView1.OptionsBehavior.Editable = true;

                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.textEditNote.Properties.ReadOnly  = true;

                this.buttonEditCompany.ButtonReadOnly  = true;
                this.buttonEditEmployee.ButtonReadOnly = true;
                this.buttonEditDepot.ButtonReadOnly    = true;

                this.buttonEditCompany.ShowButton  = false;
                this.buttonEditEmployee.ShowButton = false;
                this.buttonEditDepot.ShowButton    = false;

                this.simpleButtonAppend.Enabled         = false;
                this.simpleButtonRemove.Enabled         = false;
                this.gridView1.OptionsBehavior.Editable = false;

                break;

            default:
                break;
            }

            base.Refresh();
        }
コード例 #26
0
 public Model.InvoiceZS GetPrev(Model.InvoiceZS e)
 {
     return(sqlmapper.QueryForObject <Model.InvoiceZS>("InvoiceZS.get_prev", e));
 }
コード例 #27
0
ファイル: ViewForm.cs プロジェクト: daobataotie/EDERP
 public ViewForm(Model.InvoiceZS invoicezs)
     : this()
 {
     this.invoice = invoicezs;
 }