Beispiel #1
0
        public void InsertInvoiceCO(Model.InvoiceCO invoiceCO)
        {
            try
            {
                V.BeginTransaction();
                accessor.Insert(invoiceCO);
                string invoiceKind = this.GetInvoiceKind().ToLower();

                string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, DateTime.Now.Year);
                string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, DateTime.Now.Year, DateTime.Now.Month);
                string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, DateTime.Now.ToString("yyyy-MM-dd"));
                string sequencekey   = string.Format(invoiceKind);

                SequenceManager.Increment(sequencekey_y);
                SequenceManager.Increment(sequencekey_m);
                SequenceManager.Increment(sequencekey_d);
                SequenceManager.Increment(sequencekey);
                V.CommitTransaction();
            }
            catch
            {
                V.RollbackTransaction();
                throw;
            }
        }
Beispiel #2
0
 public ViewForm(string invoiceId)
     : this()
 {
     this.invoice = this.invoiceManager.Get(invoiceId);
     if (this.invoice == null)
     {
         throw new ArithmeticException("");
     }
 }
Beispiel #3
0
 public Model.InvoiceCO Get(string invoiceId)
 {
     Model.InvoiceCO invoice = accessor.Get(invoiceId);
     if (invoice != null)
     {
         invoice.Details = invoiceCODetailAccessor.Select(invoice);
     }
     return(invoice);
 }
Beispiel #4
0
 protected override Form GetViewForm()
 {
     Model.InvoiceCO invoice = this.SelectedItem as Model.InvoiceCO;
     if (invoice != null)
     {
         return(new EditForm(invoice.InvoiceId));
     }
     return(null);
 }
Beispiel #5
0
        public R0ch_New(string invoiceid)
        {
            InitializeComponent();

            this.invoice = this.invoiceCGManager.Get(invoiceid);


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

            this.DataSource = this.invoice.Details;

            this.xrBarCode1.Text  = this.invoice.InvoiceId;
            this.xrLabelData.Text = Properties.Resources.InvoiceCO;
            //客户信息
            this.xrLabelCustomName.Text  = this.invoice.Supplier.SupplierShortName;
            this.xrLabelLianluoName.Text = this.invoice.Supplier.SupplierContact;
            this.xrLabelCustomFax.Text   = this.invoice.Supplier.SupplierFax;
            this.xrLabelCustomTel.Text   = string.IsNullOrEmpty(this.invoice.Supplier.SupplierPhone1) ? this.invoice.Supplier.SupplierPhone2 : this.invoice.Supplier.SupplierPhone1;
            //单据信息
            this.xrLabelInvoiceDate.Text = this.invoice.InvoiceDate.Value.ToString("yyyy-MM-dd");
            this.xrLabelYJDate.Text      = this.invoice.InvoiceYjrq == null ? "" : this.invoice.InvoiceYjrq.Value.ToString("yyyy-MM-dd");
            this.xrLabel25.Text         += this.invoice.AuditEmp == null ? "" : this.invoice.AuditEmp.EmployeeName;
            this.xrLabelYeWuName.Text    = this.invoice.Employee0 == null ? "" : this.invoice.Employee0.EmployeeName;
            this.lblTaxrate.Text         = this.invoice.InvoiceTaxrate.HasValue ? this.invoice.InvoiceTaxrate.ToString() : "";
            this.lblTax.Text             = this.invoice.PrintTax;
            //this.lbl_Total.Text = this.invoice.InvoiceTotal.HasValue ? this.invoice.InvoiceTotal.Value.ToString() : "0";
            this.lbl_Total.Text = this.invoice.PrintAmount;
            this.lblNote.Text   = this.invoice.InvoiceNote;

            Model.InvoiceXO temp = this.invoiceXoManager.Get(this.invoice.InvoiceXOId);
            if (temp != null)
            {
                this.xrLabelInvoiceXOId.Text = temp.CustomerInvoiceXOId;
                this.lbl_Pihao.Text          = temp.CustomerLotNumber;
            }

            //明细信息
            this.xrTableCellProductId.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_Inumber);
            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.xrTableCellQuantity.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceProductUnit);
            this.xrTableCellProductUnit.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_OrderQuantity);
            this.xrTableCellUintPrice.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailPrice, "{0:N2}");
            //this.xrTableCellUintPrice.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_PrintPrice);
            this.xrTableCellMoney.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailMoney, "{0:N2}");
            //this.xrTableCellMoney.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_PrintMoney);
            this.xrTableCellNextWorkHouse.DataBindings.Add("Text", this.DataSource, "NextWorkHouse." + Model.WorkHouse.PROPERTY_WORKHOUSENAME);

            this.xrRichTextProductDescription.DataBindings.Add("Rtf", this.DataSource, "Product." + Model.Product.PRO_ProductDescription);

            //this.TCProductID.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_Id);
        }
Beispiel #6
0
        private void xrSubreport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            ROListDetails detail = this.xrSubreport1.ReportSource as ROListDetails;

            Model.InvoiceCO mico = this.GetCurrentRow() as Model.InvoiceCO;
            if (mico != null)
            {
                mico.Details      = this.invoiceCODetailManager.Select(mico);
                detail.MInvoiceCO = mico;
            }
        }
Beispiel #7
0
        public R0en(string invoiceid)
        {
            InitializeComponent();

            this.invoice = this.invoiceCGManager.Get(invoiceid);


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

            this.DataSource = this.invoice.Details;

            this.xrBarCode1.Text  = this.invoice.InvoiceId;
            this.xrLabelData.Text = "Purchase Order";

            this.xrLabelCustomName.Text  = this.invoice.Supplier.SupplierShortName;
            this.xrLabelLianluoName.Text = this.invoice.Supplier.SupplierContact;
            //this.xrLabelCustomTel.Text = string.IsNullOrEmpty(this.invoice.Supplier.SupplierPhone1) ? this.invoice.Supplier.SupplierPhone2 : this.invoice.Supplier.SupplierPhone1;
            this.xrLabelCustomTel.Text = this.invoice.Supplier.Email;  //改Email
            this.lblAddress.Text       = this.invoice.Supplier.CompanyAddress;
            //单据信息
            this.xrLabelInvoiceDate.Text = this.invoice.InvoiceDate.Value.ToString("yyyy-MM-dd");
            this.xrLabelYJDate.Text      = this.invoice.InvoiceYjrq == null ? "" : this.invoice.InvoiceYjrq.Value.ToString("yyyy-MM-dd");
            this.xrLabel25.Text         += this.invoice.AuditEmp == null ? "" : this.invoice.AuditEmp.EmployeeName;
            this.xrLabelYeWuName.Text    = this.invoice.Employee0 == null ? "" : this.invoice.Employee0.EmployeeName;
            Model.InvoiceXO temp = this.invoiceXoManager.Get(this.invoice.InvoiceXOId);
            if (temp != null)
            {
                this.xrLabelInvoiceXOId.Text = temp.CustomerInvoiceXOId;
            }

            this.lblTaxrate.Text = this.invoice.InvoiceTaxrate.HasValue ? this.invoice.InvoiceTaxrate.ToString() : "";
            this.lblTax.Text     = this.invoice.PrintTax;
            //this.lbl_Total.Text = this.invoice.InvoiceTotal.HasValue ? this.invoice.InvoiceTotal.Value.ToString() : "0";
            this.lbl_Total.Text      = this.invoice.PrintAmount;
            this.lblNote.Text        = this.invoice.InvoiceNote;
            this.lblShipAddress.Text = BL.Settings.CompanyAddress3;


            //明细信息
            this.xrTableCellProductId.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_Inumber);
            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.xrTableCellQuantity.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceProductUnit);
            this.xrTableCellProductUnit.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_OrderQuantity);
            //this.xrTableCellUintPrice.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailPrice, global::Helper.DateTimeParse.GetFormatA(BL.V.SetDataFormat.CGDJXiao.Value));
            this.xrTableCellUintPrice.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_PrintPrice);
            //this.xrTableCellMoney.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailMoney, global::Helper.DateTimeParse.GetFormatA(BL.V.SetDataFormat.CGJEXiao.Value));
            this.xrTableCellMoney.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_PrintMoney);

            this.xrRichTextProductDescription.DataBindings.Add("Rtf", this.DataSource, "Product." + Model.Product.PRO_ProductDescription);
        }
Beispiel #8
0
        private void _Insert(Model.InvoiceCO invoice)
        {
            invoice.InvoiceFlag   = 0;
            invoice.InsertTime    = DateTime.Now;
            invoice.UpdateTime    = DateTime.Now;
            invoice.InvoiceGZTime = DateTime.Now;
            invoice.SupplierId    = invoice.Supplier.SupplierId;
            if (invoice.Employee0 != null)
            {
                invoice.Employee0Id = invoice.Employee0.EmployeeId;
            }

            if (invoice.Employee1 != null)
            {
                invoice.Employee1Id = invoice.Employee1.EmployeeId;
            }

            if (invoice.Employee2 != null)
            {
                invoice.Employee2Id = invoice.Employee2.EmployeeId;
            }
            invoice.IsClose = false;
            accessor.Insert(invoice);
            foreach (Model.InvoiceCODetail detail in invoice.Details)
            {
                if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId))
                {
                    continue;
                }
                detail.InvoiceId         = invoice.InvoiceId;
                detail.DetailsFlag       = Convert.ToInt32(Helper.DetailsFlag.OnTheWay);
                detail.ArrivalQuantity   = 0;
                detail.NoArrivalQuantity = detail.OrderQuantity;
                detail.InvoiceCTQuantity = 0;
                Model.Product product = productAccessor.Get(detail.ProductId);
                //product.OrderOnWayQuantity += detail.NoArrivalQuantity;
                product.OrderOnWayQuantity = Convert.ToDouble(product.OrderOnWayQuantity) + Convert.ToDouble(detail.NoArrivalQuantity);
                productManager.update(product);
                // this.UpdateSql("update product set OrderOnWayQuantity=isnull( OrderOnWayQuantity,0)+" + (detail.OrderQuantity.HasValue ? detail.OrderQuantity : 0) + " where productid='" + detail.ProductId + "'");
                invoiceCODetailAccessor.Insert(detail);


                //修改手册要进量
                if (!string.IsNullOrEmpty(detail.HandbookProductId) && !string.IsNullOrEmpty(detail.HandbookId))
                {
                    bGHandbookDetail1Manager.UpdateYidingweiru(detail, detail.NoArrivalQuantity.Value);
                }
            }
        }
        public void Delete(string id)
        {
            #region 编号递减
            Model.InvoiceCO model         = this.Get(id);
            string          invoiceKind   = "CO".ToLower();
            string          sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, model.InsertTime.Value.ToString("yyyy-MM-dd"));
            Model.Sequence  sequence      = new SequenceAccessor().Get(sequencekey_d);
            if (sequence != null)
            {
                sequence.Val--;
                new SequenceAccessor().Update(sequence);
            }
            #endregion

            this.Delete <Model.InvoiceCO>(id);
        }
Beispiel #10
0
        public ROAgreement(Model.InvoiceCO invoice)
            : this()
        {
            this.lbl_Supplier.Text    = invoice.Supplier == null ? null : invoice.Supplier.ToString();
            this.lbl_Customer.Text    = BL.Settings.CompanyChineseName;
            this.lbl_AgreementId.Text = invoice.SupplierLotNumber;
            this.lbl_Date.Text        = invoice.InvoiceDate.Value.Year + "Äê" + invoice.InvoiceDate.Value.Month + "ÔÂ" + invoice.InvoiceDate.Value.Day + "ÈÕ";

            this.DataSource = invoice.Details;
            foreach (Model.InvoiceCODetail detail in invoice.Details)
            {
                detail.BGProduct = manager.SelectBGProduct(detail.HandbookId, detail.HandbookProductId);
            }

            this.TCId.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_Inumber);
            this.TCName.DataBindings.Add("Text", this.DataSource, "BGProduct." + Model.BGHandbookDetail1.PRO_ProName);
            this.TCFormat.DataBindings.Add("Text", this.DataSource, "BGProduct." + Model.BGHandbookDetail1.PRO_ProGuiGe);
            this.TCQuantity.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_OrderQuantity, "{0:0.##}");
            this.TCQuantityUnit.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceProductUnit);
            this.TCPrice.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailPrice, "{0:0.####}");
            this.TCAmount.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_YiPrice, "{0:0.##}");

            this.TCTotalMoney.Summary.FormatString     = "{0:0.##}";
            this.TCTotalMoney.Summary.Func             = SummaryFunc.Sum;
            this.TCTotalMoney.Summary.IgnoreNullValues = true;
            this.TCTotalMoney.Summary.Running          = SummaryRunning.Report;
            this.TCTotalMoney.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_YiPrice, "{0:0.##}");

            this.lblAddress.Text       = invoice.DeliveryAddress;
            this.lblPaymentWay.Text    = invoice.PaymentWay;
            this.lblAccountNumber.Text = invoice.AccountNumber;
            this.lblPayee.Text         = invoice.Payee;
            this.lblDepositBank.Text   = invoice.DepositBank;
            this.lblDelivTime.Text     = invoice.DeliveryDate;
            this.lblCheckRule.Text     = invoice.CheckRule;
            this.lblOtherAppoint.Text  = invoice.OtherAppoint;

            this.lblSupplierName.Text    = BL.Settings.CompanyChineseName;
            this.lblSupplierAddress.Text = BL.Settings.CompanyAddress1;
            this.lblSupplierTel.Text     = "TEL:" + BL.Settings.CompanyPhone + "  " + "FAX" + BL.Settings.CompanyFax;
            this.lblCustomerName.Text    = invoice.Supplier == null ? null : invoice.Supplier.SupplierShortName;
            this.lblCustomerAddress.Text = invoice.Supplier == null ? null : invoice.Supplier.CompanyAddress;
        }
Beispiel #11
0
        public RO(string invoiceid)
            : this()
        {
            this.invoice = this.invoiceCOManager.Get(invoiceid);

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

            this.DataSource             = this.invoice.Details;
            this.lblSupplierName.Text   = this.invoice.Supplier.SupplierFullName;
            this.lblContactperson.Text  = this.invoice.Supplier.SupplierContact;
            this.lblContactphone.Text   = this.invoice.Supplier.SupplierPhone1;
            this.lblFax.Text            = this.invoice.Supplier.SupplierFax;
            this.lblOrderDate.Text      = this.invoice.InvoiceDate.HasValue ? this.invoice.InvoiceDate.Value.ToString("yyyy-MM-dd") : "";
            this.lblInvoiceCusXOId.Text = invoice.InvoiceCustomXOId;
            this.lblDeliverydate.Text   = invoice.InvoiceYjrq.HasValue ? invoice.InvoiceYjrq.Value.ToString("yyyy-MM-dd") : "";

            //foreach (var item in this.invoice.Details)
            //{
            //    richTextBox1.Rtf = item.Product.ProductDescription;
            //    item.RtfHelp = richTextBox1.Text;
            //}


            this.TCNo.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_Inumber);
            //this.TCProduct.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_ProductName);
            this.lblProductName.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_ProductName);
            this.lblProductDesc.DataBindings.Add("Rtf", this.DataSource, "Product." + Model.Product.PRO_ProductDescription);
            //this.lblProductDesc.DataBindings.Add("Rtf", this.DataSource, Model.InvoiceCODetail.PRO_RtfHelp);
            this.TCQuantity.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_OrderQuantity);
            this.TCUnit.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceProductUnit);
            this.TCPrice.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailPrice, "{0:0.00}");
            this.TCAmount.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailMoney, "{0:0.000}");

            this.lblHeji.Text  = this.invoice.InvoiceHeji.HasValue ? this.invoice.InvoiceHeji.Value.ToString("0.000") : "0.000";
            this.lblTax.Text   = this.invoice.InvoiceTax.HasValue ? this.invoice.InvoiceTax.Value.ToString("0.000") : "0.000";
            this.lblTotal.Text = this.invoice.InvoiceTotal.HasValue ? this.invoice.InvoiceTotal.Value.ToString("0.000") : "0.000";

            this.lblNote.Text     = this.invoice.InvoiceNote;
            this.lblEmoloyee.Text = this.invoice.Employee0 == null ? "" : this.invoice.Employee0.EmployeeName;
        }
Beispiel #12
0
        private void simpleOrder_Click(object sender, EventArgs e)
        {
            ChooseInvoiceForm f = new ChooseInvoiceForm();

            if (f.ShowDialog(this) == DialogResult.OK)
            {
                Model.InvoiceCO temp = f.SelectedItem as Model.InvoiceCO;
                foreach (Model.InvoiceCODetail detail in new BL.InvoiceCODetailManager().Select(temp))
                {
                    if (detail.Product == null)
                    {
                        continue;
                    }
                    IList <Model.ProductImage> productImages = this._productImage.Select(detail.Product);
                    foreach (Model.ProductImage item in productImages)
                    {
                        if (item.Images.Length == 0)
                        {
                            continue;
                        }

                        #region 展示數據

                        MemoryStream ms    = new MemoryStream(item.Images);
                        Image        image = Image.FromStream(ms);
                        string       path  = Application.StartupPath + @"\Temp\" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + DateTime.Now.Millisecond.ToString() + (item.SuffixalName == "" ? ".jpg" : item.SuffixalName);
                        image.Save(path);
                        FileClass fc = new FileClass();
                        fc.filePath  = path;
                        fc.fileName  = detail.Product.ProductName;
                        fc.size      = item.Images.Length + "字节";
                        fc.image     = image;
                        fc.Extension = string.IsNullOrEmpty(item.SuffixalName) ? ".jpg" : item.SuffixalName;
                        list.Add(fc);

                        #endregion
                    }
                }
                this.gridControl1.RefreshDataSource();
            }
        }
Beispiel #13
0
        public void EvaInvoiceFlag(Model.InvoiceCO invoiceCO)
        {
            int flag = 0;

            foreach (Model.InvoiceCODetail detail in invoiceCO.Details)
            {
                flag += detail.DetailsFlag.Value;
            }
            if (flag == 0)
            {
                invoiceCO.InvoiceFlag = 0;
            }
            else if (flag < invoiceCO.Details.Count * 2)
            {
                invoiceCO.InvoiceFlag = 1;
            }
            else if (flag == invoiceCO.Details.Count * 2)
            {
                invoiceCO.InvoiceFlag = 2;
                invoiceCO.IsClose     = true;
            }
        }
Beispiel #14
0
        public void UpdateInvoiceFlag(Model.InvoiceCO invoiceCO)
        {
            int flag = 0;
            IList <Model.InvoiceCODetail> list = invoiceCODetailAccessor.Select(invoiceCO);

            foreach (Model.InvoiceCODetail detail in list)
            {
                flag += detail.DetailsFlag == null ? 0 : detail.DetailsFlag.Value;
            }
            if (flag == 0)
            {
                invoiceCO.InvoiceFlag = 0;
            }
            else if (flag < list.Count * 2)
            {
                invoiceCO.InvoiceFlag = 1;
            }
            else if (flag == list.Count * 2)
            {
                invoiceCO.InvoiceFlag = 2;
                invoiceCO.IsClose     = true;
            }
            accessor.Update(invoiceCO);
        }
Beispiel #15
0
 public Model.InvoiceCO GetPrev(Model.InvoiceCO e)
 {
     return(sqlmapper.QueryForObject <Model.InvoiceCO>("InvoiceCO.get_prev", e));
 }
Beispiel #16
0
        private void _Update(Model.InvoiceCO invoice)
        {
            Model.InvoiceCO invoiceOriginal = this.Get(invoice.InvoiceId);

            switch ((Helper.InvoiceStatus)invoiceOriginal.InvoiceStatus)
            {
                #region Draft

            case Helper.InvoiceStatus.Draft:
                switch ((Helper.InvoiceStatus)invoice.InvoiceStatus)
                {
                    #region Draft -> Draft

                case Helper.InvoiceStatus.Draft:

                    invoice.UpdateTime  = DateTime.Now;;
                    invoice.SupplierId  = invoice.Supplier.SupplierId;
                    invoice.Employee0Id = invoice.Employee0.EmployeeId;
                    accessor.Update(invoice);

                    invoiceCODetailAccessor.Delete(invoice);
                    foreach (Model.InvoiceCODetail detail in invoice.Details)
                    {
                        if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId))
                        {
                            continue;
                        }
                        detail.InvoiceCODetailId = Guid.NewGuid().ToString();
                        detail.InvoiceId         = invoice.InvoiceId;
                        invoiceCODetailAccessor.Insert(detail);
                    }
                    break;

                    #endregion

                    #region Draft -> Normal

                case Helper.InvoiceStatus.Normal:

                    invoice.UpdateTime    = DateTime.Now;;
                    invoice.SupplierId    = invoice.Supplier.SupplierId;
                    invoice.Employee0Id   = invoice.Employee0.EmployeeId;
                    invoice.Employee2Id   = invoice.Employee2.EmployeeId;
                    invoice.InvoiceGZTime = DateTime.Now;;
                    accessor.Update(invoice);

                    invoiceCODetailAccessor.Delete(invoice);
                    foreach (Model.InvoiceCODetail detail in invoice.Details)
                    {
                        if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId))
                        {
                            continue;
                        }
                        detail.InvoiceCODetailId = Guid.NewGuid().ToString();
                        detail.InvoiceId         = invoice.InvoiceId;
                        invoiceCODetailAccessor.Insert(detail);
                    }
                    break;

                    #endregion

                    #region Draft -> Null

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

                    #endregion
                }
                break;

                #endregion

                #region Normal

            case Helper.InvoiceStatus.Normal:
                switch ((Helper.InvoiceStatus)invoice.InvoiceStatus)
                {
                    #region Normal -> Draft

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

                    #endregion

                    #region Normal -> Normal

                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.UpdateTime    = DateTime.Now;
                    invoice.Employee3Id   = null;
                    invoice.InvoiceZFTime = DateTime.Now;

                    invoiceCODetailAccessor.Delete(invoiceOriginal);
                    foreach (Model.InvoiceCODetail detail in invoice.Details)
                    {
                        if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId))
                        {
                            continue;
                        }
                        detail.InvoiceId = invoice.InvoiceId;
                        if (!detail.InvoiceCTQuantity.HasValue)
                        {
                            detail.InvoiceCTQuantity = 0;
                        }
                        detail.ArrivalQuantity   = detail.ArrivalQuantity == null ? 0 : detail.ArrivalQuantity;
                        detail.NoArrivalQuantity = detail.OrderQuantity - detail.ArrivalQuantity + detail.InvoiceCTQuantity;
                        if (detail.NoArrivalQuantity < 0)
                        {
                            detail.NoArrivalQuantity = 0;
                        }

                        if (detail.NoArrivalQuantity == 0)
                        {
                            detail.DetailsFlag = Convert.ToInt32(Helper.DetailsFlag.AllArrived);
                        }
                        else
                        {
                            detail.DetailsFlag = Convert.ToInt32(Helper.DetailsFlag.OnTheWay);
                        }

                        Model.Product product = productAccessor.Get(detail.ProductId);
                        //product.OrderOnWayQuantity += detail.NoArrivalQuantity;
                        product.OrderOnWayQuantity = Convert.ToDouble(product.OrderOnWayQuantity) + Convert.ToDouble(detail.NoArrivalQuantity);
                        productManager.update(product);
                        invoiceCODetailAccessor.Insert(detail);

                        //修改手册要进量
                        if (!string.IsNullOrEmpty(detail.HandbookProductId) && !string.IsNullOrEmpty(detail.HandbookId))
                        {
                            bGHandbookDetail1Manager.UpdateYidingweiru(detail, detail.NoArrivalQuantity.Value);
                        }
                    }
                    EvaInvoiceFlag(invoice);
                    accessor.Update(invoice);

                    break;

                    #endregion

                    #region Normal -> null

                case Helper.InvoiceStatus.Null:
                    foreach (Model.InvoiceCODetail detail in invoice.Details)
                    {
                        if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId))
                        {
                            continue;
                        }
                        Model.Product product = productAccessor.Get(detail.ProductId);
                        //product.OrderOnWayQuantity -= detail.NoArrivalQuantity;
                        product.OrderOnWayQuantity = Convert.ToDouble(product.OrderOnWayQuantity) - Convert.ToDouble(detail.NoArrivalQuantity);
                        //2017年7月24日00:07:10: 可以为负,否则会导致不准
                        //product.OrderOnWayQuantity = product.OrderOnWayQuantity <= 0 ? 0 : product.OrderOnWayQuantit
                        productManager.update(product);
                        //修改手册要进量
                        if (!string.IsNullOrEmpty(detail.HandbookProductId) && !string.IsNullOrEmpty(detail.HandbookId))
                        {
                            bGHandbookDetail1Manager.UpdateYidingweiru(detail, 0 - detail.NoArrivalQuantity.Value);
                        }
                        //  invoiceCODetailAccessor.Update(detail);
                    }
                    break;

                    #endregion
                }
                break;

                #endregion

                #region Null

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

                #endregion
            }
        }
Beispiel #17
0
 public ViewForm(Model.InvoiceCO invoiceco)
     : this()
 {
     this.invoice = invoiceco;
 }
 public void Updates(Model.InvoiceCO invoiceCO)
 {
     this.Update <Model.InvoiceCO>(invoiceCO);
 }
Beispiel #19
0
        public R01_Backup(string invoiceid, string companyName, Model.Supplier supplier)
        {
            InitializeComponent();

            this.invoice = this.invoiceCGManager.Get(invoiceid);


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

            // this.invoice.Details = this.invoiceCGDetailManager.Select(this.invoice);
            this.DataSource      = this.invoice.Details;
            this.xrBarCode1.Text = this.invoice.InvoiceId;

            //CompanyInfo
            //this.xrLabelCompanyInfoName.Text = BL.Settings.CompanyChineseName;
            if (string.IsNullOrEmpty(companyName))
            {
                this.xrLabelCompanyInfoName.Text = "ALAN SAFETY COMPANY LIMITED";
            }
            else
            {
                xrLabelCompanyInfoName.HeightF  += 100;
                this.xrLabelCompanyInfoName.Text = companyName + "".PadLeft(40, ' ') + "(訂單來源:ALAN SAFETY COMPANY LIMITED)";
            }


            this.xrLabelData.Text       = Properties.Resources.InvoiceCO;
            this.xrLabelPrintDate.Text += DateTime.Now.ToShortDateString();

            //供應商信息
            //this.xrLabelCustomName.Text = this.invoice.Supplier.SupplierShortName;
            //this.xrLabelLianluoName.Text = this.invoice.Supplier.SupplierContact;
            //this.xrLabelCustomFax.Text = this.invoice.Supplier.SupplierFax;
            //this.xrLabelCustomTel.Text = string.IsNullOrEmpty(this.invoice.Supplier.SupplierPhone1) ? this.invoice.Supplier.SupplierPhone2 : this.invoice.Supplier.SupplierPhone1;
            //this.xrLabelTongYiNo.Text = this.invoice.Supplier.SupplierNumber;
            this.xrLabelCustomName.Text  = supplier.SupplierFullName;
            this.xrLabelLianluoName.Text = supplier.SupplierContact;
            this.xrLabelCustomFax.Text   = supplier.SupplierFax;
            this.xrLabelCustomTel.Text   = string.IsNullOrEmpty(supplier.SupplierPhone1) ? supplier.SupplierPhone2 : supplier.SupplierPhone1;
            this.xrLabelTongYiNo.Text    = supplier.SupplierNumber;

            //客戶信息
            if (this.invoice.Customer != null)
            {
                this.xrLabelCustomer.Text = this.invoice.Customer.CustomerFullName;
                this.xrLabelJianCe.Text   = this.invoice.Customer.CheckedStandard;
                this.lblFP.Text           = this.invoice.Customer.CustomerFP;
            }
            //单据信息
            this.xrLabelInvoiceDate.Text = this.invoice.InvoiceDate.Value.ToShortDateString();
            this.xrLabelYJDate.Text      = this.invoice.InvoiceYjrq == null ? "" : this.invoice.InvoiceYjrq.Value.ToShortDateString();
            this.xrLabelInvoiceId.Text   = this.invoice.InvoiceId;
            this.xrLabel25.Text         += this.invoice.AuditEmp == null ? "" : this.invoice.AuditEmp.EmployeeName;
            this.xrLabelYeWuName.Text    = this.invoice.Employee0 == null ? "" : this.invoice.Employee0.EmployeeName;
            this.xrLabelTotal1.Text      = global::Helper.DateTimeParse.GetSiSheWuRu(this.invoice.InvoiceTotal.Value, BL.V.SetDataFormat.CGZJXiao.Value).ToString();
            this.xrLabelNote.Text        = this.invoice.InvoiceNote;
            //this.lblBiBie.Text = this.invoice.AtCurrencyCategory == null ? "" : this.invoice.AtCurrencyCategory.ToString();
            this.lblBiBie.Text = this.invoice.Currency;
            Model.InvoiceXO temp = this.invoiceXoManager.Get(this.invoice.InvoiceXOId);
            if (temp != null)
            {
                this.xrLabelInvoiceXOId.Text = temp.CustomerInvoiceXOId;
            }
            this.xrLabelPiHao.Text = this.invoice.SupplierLotNumber;

            //明细信息
            this.xrTableCellProductId.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_Inumber);
            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.xrTableCellQuantity.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceProductUnit);
            this.xrTableCellProductUnit.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_OrderQuantity);
            this.xrTableCellUintPrice.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailPrice, "{0:0.00}");
            this.xrTableCellMoney.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailMoney, "{0:0.00}");
            //this.xrTableCellNetWeight.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_GrossWeight, "{0:0}");
            //this.xrTableCellGrossWeight.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_NetWeight, "{0:0}");
            //this.xrTableCellBulk.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_Bulk, "{0:0}");
            this.xrRichTextProductDescribe.DataBindings.Add("Rtf", this.DataSource, "Product." + Model.Product.PRO_ProductDescription);
            this.xrLabelDetailDesc.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailNote);
        }
Beispiel #20
0
 public Model.InvoiceCO GetPrev(Model.InvoiceCO e)
 {
     return(accessor.GetPrev(e));
 }
Beispiel #21
0
 public bool HasRowsAfter(Model.InvoiceCO e)
 {
     return(accessor.HasRowsAfter(e));
 }
Beispiel #22
0
 public bool HasRowsBefore(Model.InvoiceCO e)
 {
     return(accessor.HasRowsBefore(e));
 }
Beispiel #23
0
        public R01(string invoiceid)
        {
            InitializeComponent();

            this.invoice = this.invoiceCGManager.Get(invoiceid);


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

            // this.invoice.Details = this.invoiceCGDetailManager.Select(this.invoice);
            this.DataSource = this.invoice.Details;

            this.xrBarCode1.Text = this.invoice.InvoiceId;
            //CompanyInfo
            //this.xrLabelCompanyInfoName.Text = BL.Settings.CompanyChineseName;
            this.xrLabelData.Text = Properties.Resources.InvoiceCO;
            //this.xrLabelPrintDate.Text += DateTime.Now.ToShortDateString();
            //客户信息
            if (this.invoice.Supplier != null)
            {
                this.xrLabelCustomName.Text  = this.invoice.Supplier.SupplierShortName;
                this.xrLabelLianluoName.Text = this.invoice.Supplier.SupplierContact;
                this.lbl_Email.Text          = this.invoice.Supplier.Email;
                this.lbl_VenderAD.Text       = this.invoice.Supplier.CompanyAddress;
            }
            this.lbl_ShipAD.Text = BL.Settings.CompanyAddress3;
            this.lblTaxRate.Text = this.invoice.InvoiceTaxrate.HasValue ? this.invoice.InvoiceTaxrate.ToString() : "";
            //this.lblTax.Text = this.invoice.InvoiceTax.HasValue ? this.invoice.InvoiceTax.ToString() : "";
            this.lblTax.Text    = this.invoice.PrintTax;
            this.lblRemark.Text = this.invoice.InvoiceNote;
            //this.xrLabelCustomFax.Text = this.invoice.Supplier.SupplierFax;
            //this.xrLabelCustomTel.Text = string.IsNullOrEmpty(this.invoice.Supplier.SupplierPhone1) ? this.invoice.Supplier.SupplierPhone2 : this.invoice.Supplier.SupplierPhone1;
            //this.xrLabelTongYiNo.Text = this.invoice.Supplier.SupplierNumber;
            //if (this.invoice.Customer != null)
            //{
            //    this.xrLabelCustomer.Text = this.invoice.Customer.CustomerShortName;
            //    this.xrLabelJianCe.Text = this.invoice.Customer.CheckedStandard;
            //    this.lblFP.Text = this.invoice.Customer.CustomerFP;
            //}
            //单据信息
            this.xrLabelInvoiceDate.Text = this.invoice.InvoiceDate.Value.ToShortDateString();
            this.xrLabelYJDate.Text      = this.invoice.InvoiceYjrq == null ? "" : this.invoice.InvoiceYjrq.Value.ToShortDateString();
            this.xrLabelInvoiceId.Text   = this.invoice.InvoiceId;
            this.xrLabel25.Text         += this.invoice.AuditEmp == null ? "" : this.invoice.AuditEmp.EmployeeName;
            this.xrLabelYeWuName.Text    = this.invoice.Employee0 == null ? "" : this.invoice.Employee0.EmployeeName;
            //this.xrLabelTotal1.Text = global::Helper.DateTimeParse.GetSiSheWuRu(this.invoice.InvoiceTotal.Value, BL.V.SetDataFormat.CGZJXiao.Value).ToString();
            this.xrLabelTotal1.Text = this.invoice.PrintAmount;

            //this.xrLabelNote.Text = this.invoice.InvoiceNote;
            //this.lblBiBie.Text = this.invoice.AtCurrencyCategory == null ? "" : this.invoice.AtCurrencyCategory.ToString();
            //Model.InvoiceXO temp = this.invoiceXoManager.Get(this.invoice.InvoiceXOId);
            //if (temp != null)
            //{
            //    this.xrLabelInvoiceXOId.Text = temp.CustomerInvoiceXOId;

            //}
            //this.xrLabelPiHao.Text = this.invoice.SupplierLotNumber;
            //this.lblMRPId.Text = this.invoice.MRSHeaderId;

            //明细信息
            this.xrTableCellProductId.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_Inumber);
            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.xrTableCellQuantity.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceProductUnit);
            this.xrTableCellProductUnit.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_OrderQuantity);
            //this.xrTableCellUintPrice.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailPrice, global::Helper.DateTimeParse.GetFormatA(BL.V.SetDataFormat.CGDJXiao.Value));
            this.xrTableCellUintPrice.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_PrintPrice);
            //this.xrTableCellMoney.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailMoney, global::Helper.DateTimeParse.GetFormatA(BL.V.SetDataFormat.CGJEXiao.Value));
            this.xrTableCellMoney.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_PrintMoney);
            //this.xrTableCellNetWeight.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_GrossWeight, "{0:0}");
            //this.xrTableCellGrossWeight.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_NetWeight, "{0:0}");
            //this.xrTableCellBulk.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_Bulk, "{0:0}");
            this.xrRichTextProductDescribe.DataBindings.Add("Rtf", this.DataSource, "Product." + Model.Product.PRO_ProductDescription);
            //this.xrLabelDetailDesc.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailNote);
            //this.xrTableCellNextWorkHouse.DataBindings.Add("Text", this.DataSource, "NextWorkHouse." + Model.WorkHouse.PROPERTY_WORKHOUSENAME);
        }
Beispiel #24
0
        //private void AddDataRows()
        //{
        //    Model.PCOtherCheckDetail pcocDetail = new Book.Model.PCOtherCheckDetail();
        //    pcocDetail.PCOtherCheckDetailId = Guid.NewGuid().ToString();
        //    pcocDetail.PCOtherCheckId = this._PCOtherCheck.PCOtherCheckId;
        //    this._PCOtherCheck.Detail.Add(pcocDetail);

        //    this.bindingSourceDetails.Position = this.bindingSourceDetails.IndexOf(pcocDetail);
        //}
        #endregion

        //选择采购单据    2016-1-6 将数据来源从采购入库单改为采购单
        private void btnSelectCaiGou_Click(object sender, EventArgs e)
        {
            #region 原版 采购入库单
            //Book.UI.Invoices.CG.SearchCGDetail cgform = new Book.UI.Invoices.CG.SearchCGDetail();
            //if (cgform.ShowDialog() == DialogResult.OK)
            //{
            //    if (cgform.selectItems.Count > 0)
            //    {
            //        BL.InvoiceCOManager mCOM = new Book.BL.InvoiceCOManager();
            //        //Model.InvoiceCO co = cgform.Invoice;
            //        //清空数据
            //        if (this._PCOtherCheck.FromPCType < 0)
            //        {
            //            this._PCOtherCheck.Detail.Clear();
            //        }
            //        this._PCOtherCheck.FromPCType = 1;

            //        this.Ncc_Supplier.EditValue = cgform.selectItems[0].Invoice == null ? null : cgform.selectItems[0].Invoice.Supplier;//厂商
            //        Model.InvoiceCO co = new Book.Model.InvoiceCO();
            //        foreach (Model.InvoiceCGDetail item in cgform.selectItems)
            //        {
            //            Model.PCOtherCheckDetail detail = new Model.PCOtherCheckDetail();       //详细
            //            detail.PCOtherCheckDetailId = Guid.NewGuid().ToString();                //详细本身编号
            //            detail.PCOtherCheckId = this._PCOtherCheck.PCOtherCheckId;              //头编号
            //            detail.FromInvoiceDetailID = item.InvoiceCGDetailId;                    //来源详细本身编号
            //            detail.FromInvoiceID = item.InvoiceId;                                  //来源详细头编号
            //            detail.ProceduresId = null;                                             //工序编号
            //            detail.Procedures = null;                                               //加工
            //            detail.ProductId = item.ProductId;                                      //商品编号
            //            detail.Product = item.Product;                                          //品名
            //            detail.PCOtherCheckDetailDesc = item.Product == null ? "" : item.Product.ProductDescription;//说明
            //            detail.PCOtherCheckDetailQuantity = 0;                                  //数量
            //            detail.ProductUnit = detail.Product.ProduceUnit == null ? null : detail.Product.ProduceUnit.CnName;                        //单位

            //            co = mCOM.Get(item.InvoiceCOId);
            //            if (co == null)
            //            {
            //                detail.PerspectiveRate = "";
            //                detail.DeliveryDate = null;
            //            }
            //            else
            //            {
            //                try
            //                {
            //                    detail.PerspectiveRate = co.Customer == null ? "" : mCOM.Get(cgform.selectItems[0].InvoiceCOId).Customer.CheckedStandard;//透视率
            //                }
            //                catch
            //                {
            //                    detail.PerspectiveRate = "";
            //                }
            //                detail.DeliveryDate = co.InvoiceYjrq;//交期
            //            }

            //            detail.InQuantity = item.InvoiceCGDetailQuantity;                       //进厂数量
            //            detail.OutQuantity = 0;                                                 //出厂数量
            //            detail.Determinant = "";                                                //判定
            //            detail.PCOtherCheckDetailFromPC = "1";                                  //来源于 采购入库订单

            //            //客户订单编号
            //            detail.InvoiceCusXOId = co == null ? "" : co.InvoiceCustomXOId;
            //            this._PCOtherCheck.Detail.Add(detail);
            //        }
            //        this.gridControl1.RefreshDataSource();
            //    }
            //}
            //cgform.Dispose();
            //GC.Collect();
            #endregion

            Invoices.CG.CGForm f = new Book.UI.Invoices.CG.CGForm();
            if (f.ShowDialog(this) == DialogResult.OK)
            {
                if (f.key != null && f.key.Count > 0)
                {
                    if (this._PCOtherCheck.FromPCType < 0)
                    {
                        this._PCOtherCheck.Detail.Clear();
                    }
                    this._PCOtherCheck.FromPCType = 1;

                    Model.InvoiceCO co = f.key[0].Invoice;
                    this.Ncc_Supplier.EditValue = co == null ? null : co.Supplier;

                    foreach (var item in f.key)
                    {
                        Model.PCOtherCheckDetail detail = new Model.PCOtherCheckDetail();
                        detail.PCOtherCheckDetailId = Guid.NewGuid().ToString();
                        detail.PCOtherCheckId       = this._PCOtherCheck.PCOtherCheckId;
                        detail.FromInvoiceDetailID  = item.InvoiceCODetailId;
                        detail.FromInvoiceID        = item.InvoiceId;
                        detail.ProceduresId         = null;
                        detail.Procedures           = null;
                        detail.ProductId            = item.ProductId;
                        detail.Product = item.Product;
                        if (item.Product != null)
                        {
                            detail.PCOtherCheckDetailDesc = item.Product == null ? "" : item.Product.ProductDescription;
                            detail.ProductUnit            = item.Product.ProduceUnit == null ? null : item.Product.ProduceUnit.CnName;
                        }
                        detail.PCOtherCheckDetailQuantity = 0;                   //数量以后改为合格数量,进场数量即为检验数量
                        detail.InQuantity  = item.OrderQuantity - Convert.ToDouble(item.HasCheckQuantity);
                        detail.InQuantity  = detail.InQuantity < 0 ? 0 : detail.InQuantity;
                        detail.OutQuantity = 0;
                        detail.Determinant = "";
                        detail.PCOtherCheckDetailFromPC = "1";


                        if (co != null)
                        {
                            try
                            {
                                detail.PerspectiveRate = co.Customer == null ? "" : co.Customer.CheckedStandard;//透视率
                            }
                            catch
                            {
                                detail.PerspectiveRate = "";
                            }
                            detail.DeliveryDate   = co.InvoiceYjrq;//交期
                            detail.InvoiceCusXOId = co.InvoiceCustomXOId;
                        }
                        else
                        {
                            detail.PerspectiveRate = "";
                            detail.DeliveryDate    = null;
                            detail.InvoiceCusXOId  = "";
                        }

                        this._PCOtherCheck.Detail.Add(detail);
                    }
                    this.gridControl1.RefreshDataSource();
                }
            }
            f.Dispose();
            GC.Collect();
        }
Beispiel #25
0
 public Model.InvoiceCO GetNext(Model.InvoiceCO e)
 {
     return(sqlmapper.QueryForObject <Model.InvoiceCO>("InvoiceCO.get_next", e));
 }
Beispiel #26
0
        public ChooseDetailsForm(Model.InvoiceCO invoice)
        {
            InitializeComponent();

            this.invoice = invoice;
        }
Beispiel #27
0
 public IList <Model.InvoiceCGDetail> SelectCount(Model.InvoiceCO invoice)
 {
     return(accessor.SelectCount(invoice));
 }
Beispiel #28
0
 private void _TurnNull(Model.InvoiceCO invoice)
 {
     invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Null;
     _Update(invoice);
 }
Beispiel #29
0
 public Model.InvoiceCO GetNext(Model.InvoiceCO e)
 {
     return(accessor.GetNext(e));
 }
Beispiel #30
0
        public R01(string invoiceid, string companyName, Model.Supplier supplier)
        {
            InitializeComponent();

            isFirstSupplier = string.IsNullOrEmpty(companyName) ? true : false;

            this.invoice = this.invoiceCGManager.Get(invoiceid);

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

            this.DataSource = this.invoice.Details;

            //CompanyInfo
            if (isFirstSupplier)
            {
                this.xrLabelCompanyInfoName.Text = "ALAN SAFETY COMPANY LIMITED";

                //左下角签名档同供应商
                this.xrLabel14.Text = supplier.SupplierFullName;
            }
            else
            {
                xrLabelCompanyInfoName.HeightF  += 100;
                this.xrLabelCompanyInfoName.Text = companyName + "".PadLeft(40, ' ') + "(訂單來源:ALAN SAFETY COMPANY LIMITED)";

                //this.xrPanel1.LocationF.Y += 100;
                this.xrPanel1.LocationF = new PointF(this.xrPanel1.LocationF.X, this.xrPanel1.LocationF.Y + 100);

                //左下角签名档同厂商
                this.xrLabel14.Text = companyName;
                //转单单据右下角的签名档同供应商
                this.xrLabel15.Text = supplier.SupplierFullName;
            }

            this.lbl_Tel.Text = BL.Settings.CompanyPhone;
            this.lbl_Fax.Text = BL.Settings.CompanyFax;

            this.xrLabelData.Text = Properties.Resources.InvoiceCO;

            //供應商信息
            this.xrLabelCustomName.Text = supplier.SupplierFullName;

            //客戶信息
            if (this.invoice.Customer != null)
            {
                this.xrLabelCustomer.Text = this.invoice.Customer.CustomerFullName;
            }
            Model.InvoiceXO temp = this.invoiceXoManager.Get(this.invoice.InvoiceXOId);
            if (temp != null)
            {
                this.xrLabelInvoiceXOId.Text = temp.CustomerInvoiceXOId;
            }

            //单据信息
            this.xrLabelInvoiceDate.Text = this.invoice.InvoiceDate.Value.ToString("yyyy.MM.dd");
            this.xrLabelYJDate.Text      = this.invoice.InvoiceYjrq == null ? "" : this.invoice.InvoiceYjrq.Value.ToString("yyyy.MM.dd");
            this.xrLabelInvoiceId.Text   = this.invoice.InvoiceId;
            this.lbl_shipment.Text       = this.invoice.Shipment;

            //Qty總計
            this.TC_TotalQty.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_OrderQuantity);

            string currency = isFirstSupplier ? invoice.SupplierCurrency1 : invoice.SupplierCurrency2;

            this.TC_PriceUnit.Text  = string.Format("({0})", Model.ExchangeRate.GetCurrencyENNameAndSign(currency));
            this.TC_TotalPrice.Text = Model.ExchangeRate.GetCurrencyENNameAndSign(currency);

            //如果是供应商2 打印,单价,金额 * 0.8
            if (!isFirstSupplier)
            {
                foreach (var item in this.invoice.Details)
                {
                    item.InvoiceCODetailPrice = item.InvoiceCODetailPrice * 0.8m;
                    item.InvoiceCODetailMoney = Math.Round(item.InvoiceCODetailPrice.Value, 2, MidpointRounding.AwayFromZero) * (decimal)item.OrderQuantity.Value;
                }
            }


            if (currency != null)
            {
                //先将订单币别金额,转换为台币,在将台币转换为供应商1,供应商2 币别金额
                decimal invoiceCurrencyToTaibiRate = exchangeRateManager.GetRateByDateAndCurrency(invoice.InvoiceDate.Value, invoice.Currency);
                invoiceCurrencyToTaibiRate = invoiceCurrencyToTaibiRate == 0 ? 1 : invoiceCurrencyToTaibiRate;

                if (currency.Contains("台幣") || currency.Contains("台币"))
                {
                    foreach (var item in this.invoice.Details)
                    {
                        item.CurrencyPrice = item.InvoiceCODetailPrice.Value * invoiceCurrencyToTaibiRate;
                        item.CurrencyMoney = Math.Round(item.CurrencyPrice, 2, MidpointRounding.AwayFromZero) * (decimal)item.OrderQuantity.Value;
                    }

                    var taibiMoney = invoice.Details.Sum(d => d.CurrencyMoney);


                    this.lbl_TotalMoney.Text = "金額總計:新台幣" + CmycurD(Math.Round(taibiMoney, 2, MidpointRounding.AwayFromZero));

                    if ((int)taibiMoney == taibiMoney)
                    {
                        this.lbl_TotalMoney.Text += "整";
                    }

                    this.TC_TotalMoney.Text = taibiMoney.ToString("N2");
                }
                else
                {
                    decimal taibiToSupplierCurrencyRate = exchangeRateManager.GetRateByDateAndCurrency(invoice.InvoiceDate.Value, currency);
                    taibiToSupplierCurrencyRate = taibiToSupplierCurrencyRate == 0 ? 1 : taibiToSupplierCurrencyRate;

                    foreach (var item in this.invoice.Details)
                    {
                        item.CurrencyPrice = item.InvoiceCODetailPrice.Value * invoiceCurrencyToTaibiRate / taibiToSupplierCurrencyRate;
                        item.CurrencyMoney = Math.Round(item.CurrencyPrice, 2, MidpointRounding.AwayFromZero) * (decimal)item.OrderQuantity.Value;
                    }

                    var supplierCurrencyMoney = invoice.Details.Sum(d => d.CurrencyMoney);

                    this.lbl_TotalMoney.Text = string.Format("金額總計:{0}{1}{2}{3}{4}{5}匯率:{6}", currency, Model.ExchangeRate.GetCurrencyENNameAndSign(currency), supplierCurrencyMoney.ToString("N2"), "".PadLeft(20, ' '), invoice.InvoiceDate.Value.ToString("yyyy.MM.dd"), currency, taibiToSupplierCurrencyRate.ToString("0.####"));

                    this.TC_TotalMoney.Text = supplierCurrencyMoney.ToString("N2");
                }

                this.xrTableCellUintPrice.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_CurrencyPrice, "{0:N2}");
                this.xrTableCellMoney.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_CurrencyMoney, "{0:N2}");
            }
            else
            {
                this.xrTableCellUintPrice.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailPrice, "{0:N2}");
                this.xrTableCellMoney.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_InvoiceCODetailMoney, "{0:N2}");

                this.TC_TotalMoney.Text = this.invoice.InvoiceHeji.Value.ToString("N2");
            }


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

            //明细信息
            this.xrTableCellProductId.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_Inumber);
            this.TC_PRoduct_Id.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_Id);
            this.xrRichTextProductDescribe.DataBindings.Add("Rtf", this.DataSource, "Product." + Model.Product.PRO_ProductDescription);
            this.xrTableCellQuantity.DataBindings.Add("Text", this.DataSource, Model.InvoiceCODetail.PRO_OrderQuantity, "{0:N0}");
        }