Example #1
0
        //打印前触发
        private void xrSubreport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            Model.InvoiceCG invoicecg = this.GetCurrentRow() as Model.InvoiceCG;

            switch (invoicecg.Kind)
            {
            case "进退":
                Q28_2 q28_2_1 = new Q28_2();
                this.xrSubreport1.ReportSource = q28_2_1;
                q28_2_1.Invoice = invoicecg;
                break;

            case "採退":
                Q28_2 q28_2_2 = new Q28_2();
                this.xrSubreport1.ReportSource = q28_2_2;
                q28_2_2.Invoice = invoicecg;
                break;

            case "进货":
                Q28_1 q28_1_1 = new Q28_1();
                this.xrSubreport1.ReportSource = q28_1_1;
                q28_1_1.Invoice = invoicecg;
                break;

            case "採購":
                Q28_1 q28_1_2 = new Q28_1();
                this.xrSubreport1.ReportSource = q28_1_2;
                q28_1_2.Invoice = invoicecg;
                break;

            default:
                break;
            }
        }
Example #2
0
        private void xrSubreport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            Model.InvoiceCG invce = this.GetCurrentRow() as Model.InvoiceCG;
            switch (invce.Kind)
            {
            case "採購":
                Q18_1 q18_1_1 = new Q18_1();
                this.xrSubreport1.ReportSource = q18_1_1;
                q18_1_1.Invoice = invce;
                break;

            case "采购":
                Q18_1 q18_1_2 = new Q18_1();
                this.xrSubreport1.ReportSource = q18_1_2;
                q18_1_2.Invoice = invce;
                break;

            case "采退":
                Q18_2 q18_2_1 = new Q18_2();
                this.xrSubreport1.ReportSource = q18_2_1;
                q18_2_1.Invoice = invce;
                break;

            case "採退":
                Q18_2 q18_2_2 = new Q18_2();
                this.xrSubreport1.ReportSource = q18_2_2;
                q18_2_2.Invoice = invce;
                break;

            default:
                break;
            }
            //Q18_1 subReport = this.xrSubreport1.ReportSource as Q18_1;
            //subReport.Invoice =
        }
Example #3
0
 public void DeleteAtSummon(Model.InvoiceCG invoice)
 {
     Model.AtSummon atSummon = atSummonManager.GetByInvoiceCGId(invoice.InvoiceId);
     if (atSummon != null)
     {
         atSummonManager.Delete(atSummon);
     }
 }
 public Model.InvoiceCG GetDetails(Model.InvoiceCG invoicecg)
 {
     Model.InvoiceCG invoice = accessor.Get(invoicecg.InvoiceId);
     if (invoice != null)
     {
         invoice.Details = invoiceCGDetailAccessor.Select(invoice);
     }
     return(invoice);
 }
Example #5
0
 public ViewForm(Model.InvoiceCG invoice)
     : this()
 {
     if (invoice == null)
     {
         throw new ArgumentNullException();
     }
     this.invoice = invoice;
 }
Example #6
0
        public IList <Model.InvoiceCGDetail> Select(Model.InvoiceCG invoice, Model.Product productStart, Model.Product productEnd)
        {
            IList <Book.Model.InvoiceCGDetail> invoicecg = null;
            Hashtable ht = new Hashtable();

            ht.Add("invoiceId", invoice.InvoiceId);
            ht.Add("productStart", productStart == null ? null : productStart.ProductName);
            ht.Add("productEnd", productEnd == null ? null : productEnd.ProductName);
            return(sqlmapper.QueryForList <Book.Model.InvoiceCGDetail>("InvoiceCGDetail.selectByProductIdQuJian", ht));
        }
Example #7
0
        //protected override void LoadInvoices(DateTime datetime1, DateTime datetime2)
        //{
        //   // this.bindingSource1.DataSource = (this.invoiceManager as BL.InvoiceCGManager).Select().OrderByDescending(invoice => invoice.InvoiceId).ThenByDescending(i=>i.InvoiceCOId);
        //    this.bindingSource1.DataSource = from ins in (this.invoiceManager as BL.InvoiceCGManager).Select() orderby ins.InvoiceCOId descending, ins.InvoiceId descending select ins;
        //}

        protected override Form GetViewForm()
        {
            Model.InvoiceCG invoice = this.SelectedItem as Model.InvoiceCG;
            if (invoice != null)
            {
                return(new EditForm(invoice.InvoiceId));
            }
            // return new ViewForm(invoice.InvoiceId);

            return(null);
        }
Example #8
0
 protected override void LoadData()
 {
     this.bsHeader.DataSource = this._mInvoiceCGManager.Select(null, null, null, null, this.dateEditStart.DateTime, this.dateEditEnd.DateTime, null, null, null, global::Helper.DateTimeParse.NullDate, global::Helper.DateTimeParse.EndDate, null, null);//非2 显示全部
     if (this.bsHeader.Current != null)
     {
         Model.InvoiceCG icg = this.bsHeader.Current as Model.InvoiceCG;
         IList <Model.InvoiceCGDetail> icgd = _mInvoiceCGDetailManager.Select(icg);
         (this.bsHeader.Current as Model.InvoiceCG).Details = icgd;
         //this.SelectAll((this.bsHeader.Current as Model.InvoiceCG).Details);
         this.bindingSource1.DataSource = (this.bsHeader.Current as Model.InvoiceCG).Details;
     }
 }
Example #9
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     //this.LoadData();
     this.bsHeader.DataSource = this._mInvoiceCGManager.Select(null, null, this.newChooseSupplier.EditValue as Model.Supplier, this.newChooseSupplier.EditValue as Model.Supplier, this.dateEditStart.DateTime, this.dateEditEnd.DateTime, null, null, null, global::Helper.DateTimeParse.NullDate, global::Helper.DateTimeParse.EndDate, null, null);//非2 显示全部
     if (this.bsHeader.Current != null)
     {
         Model.InvoiceCG icg = this.bsHeader.Current as Model.InvoiceCG;
         IList <Model.InvoiceCGDetail> icgd = _mInvoiceCGDetailManager.Select(icg);
         (this.bsHeader.Current as Model.InvoiceCG).Details = icgd;
         //this.SelectAll((this.bsHeader.Current as Model.InvoiceCG).Details);
         this.bindingSource1.DataSource = (this.bsHeader.Current as Model.InvoiceCG).Details;
     }
 }
Example #10
0
 private void bsHeader_CurrentChanged(object sender, EventArgs e)
 {
     if (this.bsHeader.Current != null)
     {
         if ((this.bsHeader.Current as Model.InvoiceCG).Details.Count == 0)
         {
             Model.InvoiceCG icg = this.bsHeader.Current as Model.InvoiceCG;
             IList <Model.InvoiceCGDetail> icgd = _mInvoiceCGDetailManager.Select(icg);
             (this.bsHeader.Current as Model.InvoiceCG).Details = icgd;
         }
         //this.SelectAll((this.bsHeader.Current as Model.InvoiceCG).Details);
         this.bindingSource1.DataSource = (this.bsHeader.Current as Model.InvoiceCG).Details;
     }
 }
Example #11
0
        public void Delete(string id)
        {
            #region 编号递减
            Model.InvoiceCG model         = this.Get(id);
            string          invoiceKind   = "CG".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.InvoiceCG>(id);
        }
Example #12
0
        //更改查询周期
        private void btnChangeSearch_Click(object sender, EventArgs e)
        {
            Query.ConditionCOChooseForm f = new Query.ConditionCOChooseForm();
            if (f.ShowDialog(this) == DialogResult.OK)
            {
                Query.ConditionCO con = f.Condition as Query.ConditionCO;
                this.dateEditStart.DateTime = Convert.ToDateTime(con.StartInvoiceDate);
                this.dateEditEnd.DateTime   = Convert.ToDateTime(con.EndInvoiceDate);

                this.bsHeader.DataSource = this._mInvoiceCGManager.Select(con.COStartId, con.COEndId, con.SupplierStart, con.SupplierEnd, Convert.ToDateTime(con.StartInvoiceDate), Convert.ToDateTime(con.EndInvoiceDate), con.ProductStart, con.ProductEnd, con.CusXOId, con.StartJHDate, con.EndJHDate, con.InvoiceCGIdStart, con.InvoiceCGIdEnd);
                if (this.bsHeader.Current != null)
                {
                    Model.InvoiceCG icg = this.bsHeader.Current as Model.InvoiceCG;
                    IList <Model.InvoiceCGDetail> icgd = _mInvoiceCGDetailManager.Select(icg);
                    (this.bsHeader.Current as Model.InvoiceCG).Details = icgd;
                    //this.SelectAll((this.bsHeader.Current as Model.InvoiceCG).Details);
                    this.bindingSource1.DataSource = (this.bsHeader.Current as Model.InvoiceCG).Details;
                }
            }
            f.Dispose();
            GC.Collect();
        }
Example #13
0
        protected override void _ValidateForInsert(Book.Model.Invoice invoiceCG)
        {
            base._ValidateForInsert(invoiceCG);

            Model.InvoiceCG invoice = invoiceCG as Model.InvoiceCG;

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

            //if (invoice.Depot == null)
            //    throw new Helper.RequireValueException(Model.InvoiceCG.PRO_DepotId);

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

            //int count = 0;
            foreach (Model.InvoiceCGDetail detail in invoice.Details)
            {
                if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId))
                {
                    continue;
                }

                if (string.IsNullOrEmpty(detail.DepotPositionId) && Convert.ToDouble(detail.ProduceTransferQuantity) <= 0)
                {
                    //throw new Helper.RequireValueException(Model.InvoiceCGDetail.PRO_DepotPositionId);
                    throw new Helper.MessageValueException("You must select a goods allocation or fill out the transfer production quantity");
                }
                //count++;
            }
            //if (count == 0)
            //    throw new Helper.RequireValueException("InvoiceCGDetailQuantityIsZero");
        }
Example #14
0
        protected override void _ValidateForInsert(Book.Model.Invoice invoiceCG)
        {
            base._ValidateForInsert(invoiceCG);

            Model.InvoiceCG invoice = invoiceCG as Model.InvoiceCG;

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

            //if (invoice.Depot == null)
            //    throw new Helper.RequireValueException(Model.InvoiceCG.PRO_DepotId);

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

            //int count = 0;
            foreach (Model.InvoiceCGDetail detail in invoice.Details)
            {
                if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId))
                {
                    continue;
                }

                if (string.IsNullOrEmpty(detail.DepotPositionId) || detail.DepotPosition == null)
                {
                    throw new Helper.RequireValueException(Model.InvoiceCGDetail.PRO_DepotPositionId);
                }
                //count++;
            }
            //if (count == 0)
            //    throw new Helper.RequireValueException("InvoiceCGDetailQuantityIsZero");
        }
Example #15
0
        private void _Update(Model.InvoiceCG invoice)
        {
            _ValidateForUpdate(invoice);

            invoice.UpdateTime = DateTime.Now;

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

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

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

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

                    invoiceCGDetailAccessor.Delete(invoiceOriginal);
                    foreach (Model.InvoiceCGDetail detail in invoice.Details)
                    {
                        if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId))
                        {
                            continue;
                        }
                        detail.InvoiceCGDetailId = Guid.NewGuid().ToString();
                        detail.InvoiceId         = invoice.InvoiceId;
                        invoiceCGDetailAccessor.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);
                    accessor.Delete(invoiceOriginal.InvoiceId);
                    invoice.InsertTime = invoiceOriginal.InsertTime;
                    invoice.UpdateTime = DateTime.Now;
                    _Insert(invoice);
                    break;

                case Helper.InvoiceStatus.Null:

                    foreach (Model.InvoiceCGDetail detail in invoice.Details)
                    {
                        //修改订单未到和实际到数量
                        Model.InvoiceCODetail codetail = invoiceCODetailAccessor.Get(detail.InvoiceCODetailId);
                        if (codetail != null)
                        {
                            codetail.ArrivalQuantity = Convert.ToDouble(codetail.ArrivalQuantity) - Convert.ToDouble(detail.InvoiceCGDetailQuantity);

                            codetail.NoArrivalQuantity = Convert.ToDouble(codetail.OrderQuantity) - Convert.ToDouble(codetail.ArrivalQuantity) + Convert.ToDouble(codetail.InvoiceCTQuantity);
                            codetail.NoArrivalQuantity = codetail.NoArrivalQuantity < 0 ? 0 : codetail.NoArrivalQuantity;
                            if (codetail.NoArrivalQuantity < 0)
                            {
                                codetail.NoArrivalQuantity = 0;
                            }
                            if (codetail.NoArrivalQuantity == 0)
                            {
                                codetail.DetailsFlag = 2;
                            }
                            else if (codetail.NoArrivalQuantity == codetail.OrderQuantity)
                            {
                                codetail.DetailsFlag = 0;
                            }
                            else
                            {
                                codetail.DetailsFlag = 1;
                            }
                            invoiceCODetailAccessor.Update(codetail);
                            this.invoiceCOManager.UpdateInvoiceFlag(codetail.Invoice);
                        }

                        //更新产品信息
                        //if (detail.DepotPosition != null)
                        //{
                        Model.Product pro = detail.Product;
                        pro.OrderOnWayQuantity = Convert.ToDouble(pro.OrderOnWayQuantity) + Convert.ToDouble(detail.InvoiceCGDetailQuantity);
                        pro.ProductNearCGDate  = DateTime.Now;
                        if (!string.IsNullOrEmpty(detail.DepotPositionId) && detail.InvoiceCGDetaiInQuantity != 0)
                        {
                            pro.StocksQuantity = Convert.ToDouble(pro.StocksQuantity) - Convert.ToDouble(detail.InvoiceCGDetaiInQuantity);

                            //修改货位库存。
                            stockAccessor.Decrement(detail.DepotPosition, pro, detail.InvoiceCGDetaiInQuantity);
                        }
                        productManager.update(pro);
                        //}
                        // 成本
                        //productAccessor.UpdateCost1(p, p.ProductCurrentCGPrice,cgQuantity);
                    }
                    //  this.invoiceCOManager.UpdateInvoiceFlag(invoice.InvoiceCO);
                    //应收应付
                    //companyAccessor.IncrementP(invoice.Company, invoice.InvoiceOwed.Value);
                    break;
                }
                break;

            case Helper.InvoiceStatus.Null:
                throw new InvalidOperationException();
            }
        }
Example #16
0
 public void Updates(Model.InvoiceCG invoice)
 {
     accessor.Update(invoice);
 }
Example #17
0
        private void _Insert(Model.InvoiceCG invoice)
        {
            //   Model.InvoiceCO invoiceCO = invoice.InvoiceCO; //修改订单状态
            _ValidateForInsert(invoice);
            if (this.HasRows(invoice.InvoiceId))
            {
                throw new Helper.InvalidValueException(Model.InvoiceCG.PRO_InvoiceCOId);
            }
            // int flag = 0;
            //foreach (Model.InvoiceCGDetail detail in invoice.Details)
            //{
            //    if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) continue;
            //    if (!string.IsNullOrEmpty( detail.DepotPositionId))
            //        flag=1;
            //}
            //if(flag==0)
            //    throw new Helper.RequireValueException(Model.InvoiceCGDetail.PRO_DepotPositionId);

            if (invoice.Employee0 == null)
            {
                throw new Helper.MessageValueException("Attn can not be empty!");
            }

            invoice.SupplierId = invoice.Supplier.SupplierId;
            if (invoice.Depot != null)
            {
                invoice.DepotId = invoice.Depot.DepotId;
            }

            invoice.Employee0Id = invoice.Employee0.EmployeeId;
            invoice.Employee1Id = invoice.Employee1 == null ? null : invoice.Employee1.EmployeeId;
            //过账人
            invoice.Employee2Id = invoice.Employee2 == null ? null : invoice.Employee2.EmployeeId;
            //过账时间
            invoice.InvoiceGZTime = DateTime.Now;
            invoice.InvoiceLRTime = DateTime.Now;

            accessor.Insert(invoice);

            foreach (Model.InvoiceCGDetail detail in invoice.Details)
            {
                //if (detail.InvoiceCGDetaiInQuantity + invoiceCGDetailAccessor.CountInDepotQuantity(detail.InvoiceCODetailId) > detail.OrderQuantity)
                //    throw new Helper.MessageValueException("序號: " + (detail.Inumber == null ? "" : detail.Inumber.ToString()) + " 總入庫數量大于訂貨數量!");
                if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId))
                {
                    continue;
                }
                Model.Product p = productAccessor.Get(detail.ProductId);

                detail.InvoiceId       = invoice.InvoiceId;
                detail.DepotPositionId = detail.DepotPositionId;
                invoiceCGDetailAccessor.Insert(detail);
                Model.InvoiceCODetail codetail = invoiceCODetailAccessor.Get(detail.InvoiceCODetailId);

                if (codetail != null)
                {
                    //if (detail.InvoiceCGDetailQuantity > codetail.NoArrivalQuantity)
                    //{
                    //    throw new Helper.InvalidValueException("CGQgtCOQ");
                    //}
                    //进货量大于订单数量 修改订单数量
                    //if (detail.InvoiceCGDetailQuantity >= codetail.NoArrivalQuantity)
                    //{
                    //    //invoiceCO.InvoiceHeji-=codetail.InvoiceCODetailMoney;
                    //    codetail.DetailsFlag = (int)Helper.DetailsFlag.AllArrived;
                    //    // codetail.OrderQuantity = detail.InvoiceCGDetailQuantity + codetail.ArrivalQuantity;
                    //    // codetail.InvoiceCODetailMoney = codetail.InvoiceCODetailPrice *decimal.Parse(codetail.OrderQuantity.Value.ToString());
                    //    // codetail.TotalMoney = codetail.InvoiceCODetailMoney;
                    //    // invoiceCO.InvoiceHeji += codetail.InvoiceCODetailMoney;
                    //    //暂时 未考虑税率
                    //    // invoiceCO.InvoiceTotal = invoiceCO.InvoiceHeji;
                    //}
                    //else
                    //{
                    //    if (codetail.ArrivalQuantity == 0)
                    //    { codetail.DetailsFlag = (int)Helper.DetailsFlag.OnTheWay; }
                    //    else
                    //        codetail.DetailsFlag = (int)Helper.DetailsFlag.PartArrived;
                    //}

                    codetail.ArrivalQuantity = Convert.ToDouble(codetail.ArrivalQuantity) + Convert.ToDouble(detail.InvoiceCGDetailQuantity);

                    codetail.NoArrivalQuantity = Convert.ToDouble(codetail.OrderQuantity) - Convert.ToDouble(codetail.ArrivalQuantity) + Convert.ToDouble(codetail.InvoiceCTQuantity);
                    codetail.NoArrivalQuantity = codetail.NoArrivalQuantity < 0 ? 0 : codetail.NoArrivalQuantity;

                    if (codetail.NoArrivalQuantity == 0)
                    {
                        codetail.DetailsFlag = (int)Helper.DetailsFlag.AllArrived;
                    }
                    else if (codetail.ArrivalQuantity == 0)
                    {
                        codetail.DetailsFlag = (int)Helper.DetailsFlag.OnTheWay;
                    }
                    else
                    {
                        codetail.DetailsFlag = (int)Helper.DetailsFlag.PartArrived;
                    }

                    invoiceCODetailAccessor.Update(codetail);
                    this.invoiceCOManager.UpdateInvoiceFlag(codetail.Invoice);
                }

                //更新产品信息00


                p.OrderOnWayQuantity = Convert.ToDouble(p.OrderOnWayQuantity) - Convert.ToDouble(detail.InvoiceCGDetailQuantity);
                p.OrderOnWayQuantity = p.OrderOnWayQuantity < 0 ? 0 : p.OrderOnWayQuantity;
                p.ProductNearCGDate  = DateTime.Now;
                if (codetail != null)//单价 以后 在进库单 保存
                {
                    p.NewestCost = codetail.InvoiceCODetailPrice.HasValue ? codetail.InvoiceCODetailPrice.Value : 0;
                }
                if (!string.IsNullOrEmpty(detail.DepotPositionId) && detail.InvoiceCGDetaiInQuantity != 0)
                {
                    p.StocksQuantity = Convert.ToDouble(p.StocksQuantity) + Convert.ToDouble(detail.InvoiceCGDetaiInQuantity);
                    //修改货位库存。
                    stockAccessor.Increment(detail.DepotPosition, p, detail.InvoiceCGDetaiInQuantity);
                }
                // 成本
                // productAccessor.UpdateCost1(p, p.ProductCurrentCGPrice,cgQuantity);
                productManager.update(p);
            }



            //应收应付
            //companyAccessor.IncrementP(invoice.Company, invoice.InvoiceOwed.Value);
        }
Example #18
0
 private void _TurnNull(Model.InvoiceCG invoice)
 {
     invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Null;
     _Update(invoice);
 }
Example #19
0
 public IList <Model.InvoiceCGDetail> Select(Model.InvoiceCG invoice, Model.Product productStart, Model.Product productEnd)
 {
     return(accessor.Select(invoice, productStart, productEnd));
 }
Example #20
0
 public void Insert(Model.InvoiceCG e)
 {
     this.Insert <Model.InvoiceCG>(e);
 }
Example #21
0
 public IList <Model.InvoiceCGDetail> SelectbyinvoiceIdfz(Model.InvoiceCG invoicecg)
 {
     return(sqlmapper.QueryForList <Model.InvoiceCGDetail>("InvoiceCGDetail.selectbyinvoiceIdfz", invoicecg.InvoiceId));
 }
Example #22
0
 public Model.InvoiceCG GetPrev(Model.InvoiceCG e)
 {
     return(sqlmapper.QueryForObject <Model.InvoiceCG>("InvoiceCG.get_prev", e));
 }
Example #23
0
 public bool HasRowsAfter(Model.InvoiceCG e)
 {
     return(sqlmapper.QueryForObject <bool>("InvoiceCG.has_rows_after", e));
 }
Example #24
0
 public bool HasRowsBefore(Model.InvoiceCG e)
 {
     return(sqlmapper.QueryForObject <bool>("InvoiceCG.has_rows_before", e));
 }
Example #25
0
 public void Update(Model.InvoiceCG e)
 {
     this.Update <Model.InvoiceCG>(e);
 }
Example #26
0
 public Model.InvoiceCG Get(string invoiceId)
 {
     Model.InvoiceCG invoice = accessor.Get(invoiceId);
     invoice.Details = invoiceCGDetailAccessor.Select(invoice);
     return(invoice);
 }
Example #27
0
 /// <summary>
 /// 获取属于指定采购单的明细
 /// </summary>
 /// <param name="invoice"></param>
 /// <returns></returns>
 public IList <Model.InvoiceCGDetail> Select(Model.InvoiceCG invoice)
 {
     return(accessor.Select(invoice));
 }
Example #28
0
        private void _Insert(Model.InvoiceCG invoice)
        {
            //   Model.InvoiceCO invoiceCO = invoice.InvoiceCO; //修改订单状态
            _ValidateForInsert(invoice);
            if (this.HasRows(invoice.InvoiceId))
            {
                throw new Helper.InvalidValueException(Model.InvoiceCG.PRO_InvoiceCOId);
            }
            // int flag = 0;
            //foreach (Model.InvoiceCGDetail detail in invoice.Details)
            //{
            //    if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) continue;
            //    if (!string.IsNullOrEmpty( detail.DepotPositionId))
            //        flag=1;
            //}
            //if(flag==0)
            //    throw new Helper.RequireValueException(Model.InvoiceCGDetail.PRO_DepotPositionId);

            if (invoice.Employee0 == null)
            {
                throw new Helper.MessageValueException("操作員不能為空!");
            }

            invoice.SupplierId = invoice.Supplier.SupplierId;
            if (invoice.Depot != null)
            {
                invoice.DepotId = invoice.Depot.DepotId;
            }

            invoice.Employee0Id = invoice.Employee0.EmployeeId;
            invoice.Employee1Id = invoice.Employee1 == null ? null : invoice.Employee1.EmployeeId;
            //过账人
            invoice.Employee2Id = invoice.Employee2 == null ? null : invoice.Employee2.EmployeeId;
            //过账时间
            invoice.InvoiceGZTime = DateTime.Now;
            invoice.InvoiceLRTime = DateTime.Now;

            accessor.Insert(invoice);

            foreach (Model.InvoiceCGDetail detail in invoice.Details)
            {
                if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId))
                {
                    continue;
                }
                Model.Product p = productAccessor.Get(detail.ProductId);

                detail.InvoiceId       = invoice.InvoiceId;
                detail.DepotPositionId = detail.DepotPositionId;
                invoiceCGDetailAccessor.Insert(detail);
                Model.InvoiceCODetail codetail = invoiceCODetailAccessor.Get(detail.InvoiceCODetailId);

                if (codetail != null)
                {
                    //if (detail.InvoiceCGDetailQuantity > codetail.NoArrivalQuantity)
                    //{
                    //    throw new Helper.InvalidValueException("CGQgtCOQ");
                    //}
                    //进货量大于订单数量 修改订单数量
                    if (detail.InvoiceCGDetailQuantity >= codetail.NoArrivalQuantity)
                    {
                        //invoiceCO.InvoiceHeji-=codetail.InvoiceCODetailMoney;
                        codetail.DetailsFlag = (int)Helper.DetailsFlag.AllArrived;
                        // codetail.OrderQuantity = detail.InvoiceCGDetailQuantity + codetail.ArrivalQuantity;
                        // codetail.InvoiceCODetailMoney = codetail.InvoiceCODetailPrice *decimal.Parse(codetail.OrderQuantity.Value.ToString());
                        // codetail.TotalMoney = codetail.InvoiceCODetailMoney;
                        // invoiceCO.InvoiceHeji += codetail.InvoiceCODetailMoney;
                        //暂时 未考虑税率
                        // invoiceCO.InvoiceTotal = invoiceCO.InvoiceHeji;
                    }
                    else
                    {
                        if (codetail.ArrivalQuantity == 0)
                        {
                            codetail.DetailsFlag = (int)Helper.DetailsFlag.OnTheWay;
                        }
                        else
                        {
                            codetail.DetailsFlag = (int)Helper.DetailsFlag.PartArrived;
                        }
                    }

                    codetail.ArrivalQuantity = Convert.ToDouble(codetail.ArrivalQuantity) + Convert.ToDouble(detail.InvoiceCGDetailQuantity);
                    double noArr = codetail.NoArrivalQuantity.Value;
                    codetail.NoArrivalQuantity = Convert.ToDouble(codetail.OrderQuantity) - Convert.ToDouble(codetail.ArrivalQuantity) + Convert.ToDouble(codetail.InvoiceCTQuantity);


                    codetail.NoArrivalQuantity = codetail.NoArrivalQuantity < 0 ? 0 : codetail.NoArrivalQuantity;

                    invoiceCODetailAccessor.Update(codetail);
                    this.invoiceCOManager.UpdateInvoiceFlag(codetail.Invoice);



                    //修改手册要进量
                    if (!string.IsNullOrEmpty(detail.HandbookProductId) && !string.IsNullOrEmpty(detail.HandbookId))
                    {
                        bGHandbookDetail1Manager.UpdateYidingweiru(codetail, 0 - (noArr - codetail.NoArrivalQuantity.Value));
                    }

                    //p.OrderOnWayQuantity += codetail.NoArrivalQuantity.Value - noArr;
                }

                //更新产品信息00

                if (!string.IsNullOrEmpty(detail.InvoiceCODetailId))
                {
                    p.OrderOnWayQuantity = Convert.ToDouble(p.OrderOnWayQuantity) - Convert.ToDouble(detail.InvoiceCGDetailQuantity);
                }
                //2017年7月24日00:07:10: 可以为负,否则会导致不准
                //p.OrderOnWayQuantity = p.OrderOnWayQuantity < 0 ? 0 : p.OrderOnWayQuantity;
                p.ProductNearCGDate = DateTime.Now;
                if (codetail != null)//单价 以后 在进库单 保存
                {
                    p.NewestCost = codetail.InvoiceCODetailPrice.HasValue ? codetail.InvoiceCODetailPrice.Value : 0;
                }
                if (!string.IsNullOrEmpty(detail.DepotPositionId) && detail.InvoiceCGDetaiInQuantity != 0)
                {
                    p.StocksQuantity = Convert.ToDouble(p.StocksQuantity) + detail.InvoiceCGDetaiInQuantity;
                    //修改货位库存。
                    stockAccessor.Increment(detail.DepotPosition, p, detail.InvoiceCGDetaiInQuantity);
                }
                // 成本
                // productAccessor.UpdateCost1(p, p.ProductCurrentCGPrice,cgQuantity);
                productManager.update(p);
                //修改手册已进
                if (!string.IsNullOrEmpty(detail.HandbookProductId) && !string.IsNullOrEmpty(detail.HandbookId))
                {
                    bGHandbookDetail1Manager.UpdateBeeIn(detail.HandbookId, detail.HandbookProductId, detail.InvoiceCGDetailQuantity.Value);
                }
            }

            //应收应付
            //companyAccessor.IncrementP(invoice.Company, invoice.InvoiceOwed.Value);
        }
Example #29
0
 public Model.InvoiceCG GetNext(Model.InvoiceCG e)
 {
     return(sqlmapper.QueryForObject <Model.InvoiceCG>("InvoiceCG.get_next", e));
 }
Example #30
0
 public IList <Model.InvoiceCGDetail> SelectbyinvoiceIdfz(Model.InvoiceCG invoicecg)
 {
     return(accessor.SelectbyinvoiceIdfz(invoicecg));
 }