示例#1
0
        private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            if (e.ListSourceRowIndex < 0)
            {
                return;
            }
            Model.CustomerProducts p = null;

            IList <Model.InvoiceXSDetail> details = this.bindingSource1.DataSource as IList <Model.InvoiceXSDetail>;

            if (details == null || details.Count <= 0)
            {
                return;
            }
            p = details[e.ListSourceRowIndex].PrimaryKey;
            if (p == null)
            {
                return;
            }
            switch (e.Column.Name)
            {
            case "colProductId":
                e.DisplayText = p.CustomerProductId;
                break;
            }
        }
示例#2
0
        /// <summary>
        /// Delete CustomerProducts by primary key.
        /// </summary>
        public void Delete(Model.CustomerProducts customerProducts)
        {
            //
            // todo:add other logic here
            //
            try
            {
                BL.V.BeginTransaction();
                accessor.Delete(customerProducts.PrimaryKeyId);


                //指定客户产品对应产品编号
                //添加的客户产品名稱添加至产品表CustomerProductName 字段



                productAccessor.Delete(customerProducts.CustomerProductProceName);
                BL.V.CommitTransaction();
            }
            catch
            {
                BL.V.RollbackTransaction();
                throw;
            }
        }
示例#3
0
        private void simpleButtonAppend_Click(object sender, EventArgs e)
        {
            Model.Customer customer = this.buttonEditCompany.EditValue as Model.Customer;
            if (customer == null)
            {
                MessageBox.Show("Õˆßx„t¿Í‘ô£¡", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            this.bindingSource2.DataSource = this.customerProductManager.Select(customer);

            Book.UI.Settings.BasicData.Customs.ChooseCustomerProductForm f = new Book.UI.Settings.BasicData.Customs.ChooseCustomerProductForm(customer);



            if (f.ShowDialog(this) == DialogResult.OK)
            {
                Model.InvoiceZSDetail detail = new Book.Model.InvoiceZSDetail();
                detail.InvoiceZSDetailId = Guid.NewGuid().ToString();
                detail.Invoice           = this.invoice;
                // detail.Product = f.SelectedItem as Model.CustomerProducts;

                Model.CustomerProducts product = f.SelectedItem as Model.CustomerProducts;
                detail.PrimaryKey   = product;
                detail.PrimaryKeyId = product.PrimaryKeyId;
                //detail.InvoiceProductUnit = detail.Product.ProductBaseUnit;
                detail.InvoiceZSDetailQuantity = 0;
                detail.InvoiceZSDetailPrice    = decimal.Zero;
                detail.InvoiceZSDetailMoney    = decimal.Zero;
                detail.InvoiceZSDetailNote     = "";
                this.invoice.Details.Add(detail);
                this.gridControl1.RefreshDataSource();

                this.bindingSource1.Position = this.bindingSource1.IndexOf(detail);
            }
        }
示例#4
0
        private void gridView1_ShowingEditor(object sender, CancelEventArgs e)
        {
            if (this.gridView1.FocusedColumn.Name == "gridColumn1")
            {
                if (this.gridView1.FocusedColumn.ColumnEdit is DevExpress.XtraEditors.Repository.RepositoryItemComboBox)
                {
                    Model.CustomerProducts p = (this.gridView1.GetRow(this.gridView1.FocusedRowHandle) as Model.InvoiceZSDetail).PrimaryKey;

                    this.repositoryItemComboBox1.Items.Clear();
                    // if (!string.IsNullOrEmpty(p.UnitGroup))
                    {
                        BL.ProductUnitManager     manager  = new Book.BL.ProductUnitManager();
                        IList <Model.ProductUnit> unitList = manager.Select(p.UnitGroup);
                        foreach (Model.ProductUnit item in unitList)
                        {
                            this.repositoryItemComboBox1.Items.Add(item.CnName);
                        }
                    }

                    //if (!string.IsNullOrEmpty(p.ProductBaseUnit))
                    //{
                    //    this.repositoryItemComboBox1.Items.Add(p.ProductBaseUnit);
                    //}
                    //if (!string.IsNullOrEmpty(p.ProductInnerPackagingUnit))
                    //{
                    //    this.repositoryItemComboBox1.Items.Add(p.ProductInnerPackagingUnit);
                    //}
                    //if (!string.IsNullOrEmpty(p.ProductOuterPackagingUnit))
                    //{
                    //    this.repositoryItemComboBox1.Items.Add(p.ProductOuterPackagingUnit);
                    //}
                }
            }
        }
示例#5
0
        private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            Model.InvoiceZSDetail detail = this.gridView1.GetRow(e.RowHandle) as Model.InvoiceZSDetail;
            if (e.Column == this.gridproductId)
            {
                if (detail != null)
                {
                    Model.CustomerProducts p = customerProductManager.Get(e.Value.ToString());
                    detail.InvoiceZSDetailId       = Guid.NewGuid().ToString();
                    detail.InvoiceZSDetailMoney    = 0;
                    detail.InvoiceZSDetailNote     = "";
                    detail.InvoiceZSDetailPrice    = 0;
                    detail.InvoiceZSDetailQuantity = 0;

                    detail.PrimaryKey   = p;
                    detail.PrimaryKeyId = p.PrimaryKeyId;
                    //detail.InvoiceProductUnit = detail.Product.ProductBaseUnit;
                    this.bindingSource1.Position = this.bindingSource1.IndexOf(detail);
                }
                this.gridControl1.RefreshDataSource();
            }
            if (e.Column == this.gridColumnDepotPisition)
            {
                if (detail != null)
                {
                    Model.DepotPosition position = new BL.DepotPositionManager().Get(e.Value.ToString());
                    detail.DepotPosition   = position;
                    detail.DepotPositionId = position.DepotPositionId;
                }
                this.gridControl1.RefreshDataSource();
            }
        }
示例#6
0
        public void MyClick(ref ChooseItem item)
        {
            ChooseCustomerProductForm f = new ChooseCustomerProductForm(_customer);

            if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Model.CustomerProducts customer = f.SelectedItem as Model.CustomerProducts;
                item = new ChooseItem(customer, customer.CustomerProductId, customer.CustomerProductName);
            }
        }
示例#7
0
 /// <summary>
 /// Select by primary key.
 /// </summary>
 public Model.CustomerProducts Get(string primaryKeyId)
 {
     Model.CustomerProducts product = accessor.Get(primaryKeyId);
     if (product != null)
     {
         //product.CustomerProductProcessList = SelectProcessCategory(product);
         //product.CustomerProductsBomInfos = SelectBomInfos(product);
     }
     return(product);
 }
示例#8
0
 public void MyLeave(ref ChooseItem item)
 {
     BL.CustomerProductsManager manager  = new Book.BL.CustomerProductsManager();
     Model.CustomerProducts     customer = manager.GetById(item.ButtonText);
     if (customer != null)
     {
         item.EditValue  = customer;
         item.LabelText  = customer.CustomerProductName;
         item.ButtonText = customer.CustomerProductId;
     }
 }
示例#9
0
        /// <summary>
        /// 货品编号开始区间
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonEditProductStart_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            string customerStart = string.IsNullOrEmpty(this.buttonEditCustomerStart.Text) ? "" : this.buttonEditCustomerStart.Text;
            string customerEnd   = string.IsNullOrEmpty(this.buttonEditCustomerEnd.Text) ? "zzzzzzz" : this.buttonEditCustomerEnd.Text;

            Settings.BasicData.Customs.ChooseCustomerProductForm f = new Settings.BasicData.Customs.ChooseCustomerProductForm(customerStart, customerEnd);
            if (f.ShowDialog(this) == DialogResult.OK)
            {
                Model.CustomerProducts product = f.SelectedItem as Model.CustomerProducts;
                if (product != null)
                {
                    this.buttonEditProductStart.Text = product.CustomerProductId;
                }
            }
        }
示例#10
0
        private void gridView1_ShowingEditor(object sender, CancelEventArgs e)
        {
            if (this.gridView1.FocusedColumn.Name == this.colInvoiceProductUnit.Name)
            {
                if (this.gridView1.FocusedColumn.ColumnEdit is DevExpress.XtraEditors.Repository.RepositoryItemComboBox)
                {
                    Model.CustomerProducts p = (this.gridView1.GetRow(this.gridView1.FocusedRowHandle) as Model.InvoiceXJDetail).PrimaryKey;

                    this.repositoryItemComboBox1.Items.Clear();

                    IList <Model.ProductUnit> units = productUnitManager.Select(p.UnitGroupId);

                    foreach (Model.ProductUnit ut in units)
                    {
                        this.repositoryItemComboBox1.Items.Add(ut.CnName);
                    }
                }
            }
        }
示例#11
0
        private void Validate(Model.CustomerProducts customerProducts)
        {
            if (string.IsNullOrEmpty(customerProducts.CustomerProductId))
            {
                throw new Helper.RequireValueException(Model.CustomerProducts.PRO_CustomerProductId);
            }

            if (customerProducts.Customer == null)
            {
                throw new Helper.RequireValueException(Model.CustomerProducts.PRO_CustomerId);
            }

            if (string.IsNullOrEmpty(customerProducts.ProductId))
            {
                throw new Helper.RequireValueException(Model.CustomerProducts.PRO_ProductId);
            }

            //if (this.IsExistsCustomerProductId(customerProducts.CustomerProductId, customerProducts.PrimaryKeyId))
            //    throw new Helper.MessageValueException("商品型號已經存在!");
        }
示例#12
0
        /// <summary>
        /// 计算装箱记录
        /// </summary>
        /// <param name="invoicezx"></param>
        /// <param name="产品数量"></param>
        /// <param name="装箱编号或日期不为空的记录条数"></param>
        private void DetailAdd(Model.InvoiceZX invoicezx, int BoxNum, int detailnum, Model.CustomerProducts cp)
        {
            for (int i = 0; i < BoxNum - detailnum; i++)
            {
                Model.InvoiceZX Rinvoicezx = new Book.Model.InvoiceZX();
                Rinvoicezx.InvoiceZXId      = Guid.NewGuid().ToString();
                Rinvoicezx.ParentInvoceZXId = invoicezx.InvoiceZXId;
                Rinvoicezx.Product          = invoicezx.Product;
                Rinvoicezx.ProductId        = invoicezx.ProductId;
                Rinvoicezx.Customer         = invoicezx.Customer;
                Rinvoicezx.CustomerId       = invoicezx.CustomerId;
                Rinvoicezx.XOcustomer       = invoicezx.XOcustomer;
                Rinvoicezx.XOcustomerId     = invoicezx.XOcustomerId;
                Rinvoicezx.PackingNum       = cp.PackingSpecification;
                Rinvoicezx.UNITPRICE        = invoicezx.UNITPRICE;
                //if (i == BoxNum - detailnum - 1 && invoicezx.ProductNum % cp.PackingSpecification != 0)
                //    Rinvoicezx.PackingNum = invoicezx.ProductNum % cp.PackingSpecification;

                if (cp != null)
                {
                    Rinvoicezx.BLong     = cp.BLong;
                    Rinvoicezx.BWide     = cp.BWide;
                    Rinvoicezx.BHigh     = cp.BHigh;
                    Rinvoicezx.BWeight   = cp.JWeight;
                    Rinvoicezx.AllWeight = cp.MWeight;
                    Rinvoicezx.Caiji     = cp.Caiji;
                }

                RInvoiceZXList.Add(Rinvoicezx);
            }
            for (int n = 0; n < detailnum - BoxNum; n++)
            {
                this.RInvoiceZXList.Remove(this.RInvoiceZXList.Where(d => d.ParentInvoceZXId == invoicezx.InvoiceZXId).ToList <Model.InvoiceZX>().Last <Model.InvoiceZX>());
            }
            if (invoicezx.ProductNum % cp.PackingSpecification != 0)
            {
                this.RInvoiceZXList.Where(d => d.ParentInvoceZXId == invoicezx.InvoiceZXId).ToList <Model.InvoiceZX>().Last <Model.InvoiceZX>().PackingNum = invoicezx.ProductNum % cp.PackingSpecification;
            }
        }
 public void Update(Model.CustomerProducts e)
 {
     this.Update <Model.CustomerProducts>(e);
 }
示例#14
0
        /// <summary>
        /// 添加客户订单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            XS.SearcharInvoiceXSForm f  = new Book.UI.Invoices.XS.SearcharInvoiceXSForm();
            Model.CustomerProducts   cp = null;
            if (f.ShowDialog(this) == DialogResult.OK)
            {
                if (f.key != null && f.key.Count > 0)
                {
                    Model.CustomerMarks        mark          = null;
                    Model.InvoicePackingDetail packingDetail = null;
                    //if (this._invoicePacking.Details != null && this._invoicePacking.Details.Count > 1)
                    //Id = 65 + this._invoicePacking.Details.Count;
                    foreach (Model.InvoiceXODetail detail in f.key)
                    {
                        if (this._invoicePacking.Details.Where(d => d.InvoiceXODetailId == detail.InvoiceXODetailId).ToList().Count > 0)
                        {
                            MessageBox.Show("已存在相同的訂單!", this.Text, MessageBoxButtons.OK);
                            continue;
                        }
                        packingDetail = new Book.Model.InvoicePackingDetail();
                        //packingDetail.InvoicePackingDetailId = this._invoicePackingDetailManager.GetId();
                        //this._invoicePackingDetailManager.TiGuiExists(packingDetail);
                        packingDetail.InvoicePackingDetailId = Guid.NewGuid().ToString();
                        packingDetail.InvoicePackingId       = this._invoicePacking.InvoicePackingId;
                        packingDetail.HandbookId             = detail.HandbookId;
                        packingDetail.HandbookProductId      = detail.HandbookProductId;
                        packingDetail.Product           = detail.Product;
                        packingDetail.ProductId         = detail.ProductId;
                        packingDetail.Customer          = detail.Invoice.Customer;
                        packingDetail.CustomerId        = detail.Invoice.CustomerId;
                        packingDetail.XOCustomer        = detail.Invoice.xocustomer;
                        packingDetail.XOCustomerId      = detail.Invoice.xocustomerId;
                        packingDetail.UnitPrice         = detail.InvoiceXODetailPrice;
                        packingDetail.InvoiceXOQuantity = detail.InvoiceXODetailQuantity0 == null ? 0 : detail.InvoiceXODetailQuantity0;
                        packingDetail.PackingNum        = packingDetail.InvoiceXOQuantity;
                        packingDetail.HasFPQuantity     = 0;
                        packingDetail.Amount            = Convert.ToDecimal(packingDetail.PackingNum) * packingDetail.UnitPrice;
                        packingDetail.InvoiceXOId       = detail.InvoiceId;
                        packingDetail.InvoiceXODetailId = detail.InvoiceXODetailId;
                        packingDetail.ProductUnit       = detail.InvoiceProductUnit;
                        packingDetail.WeightUnit        = "KGS";
                        packingDetail.PriceUnit         = "USD";
                        packingDetail.BGHandBookProduct = new BL.BGHandbookDetail1Manager().SelectProName(detail.HandbookId, detail.HandbookProductId);

                        if (detail.Invoice.CustomerMarks != null && this._invoicePacking.Marks.Where(d => d.CustomerMarksName == detail.Invoice.CustomerMarks).ToList().Count < 1)
                        {
                            mark = new Book.Model.CustomerMarks();
                            mark.CustomerMarksId   = Guid.NewGuid().ToString();
                            mark.InvoicePackingId  = this._invoicePacking.InvoicePackingId;
                            mark.CustomerMarksName = detail.Invoice.CustomerMarks;

                            this._invoicePacking.Marks.Add(mark);
                        }
                        if (packingDetail.Product != null && !(string.IsNullOrEmpty(packingDetail.Product.CustomerProductName)) && !(string.IsNullOrEmpty(packingDetail.Product.CustomerId)))
                        {
                            cp = new BL.CustomerProductsManager().SelectByCustomerProductProceId(packingDetail.ProductId);
                        }
                        if (cp != null)
                        {
                            packingDetail.BLong       = cp.BLong;
                            packingDetail.BWidth      = cp.BWide;
                            packingDetail.BHeight     = cp.BHigh;
                            packingDetail.UnitJWeight = cp.JWeight;
                            packingDetail.UnitMWeight = cp.MWeight;
                            packingDetail.UnitCaiji   = cp.Caiji;
                            packingDetail.UnitNum     = cp.PackingSpecification;
                            if (packingDetail.UnitNum > packingDetail.InvoiceXOQuantity)
                            {
                                packingDetail.BoxNum     = 1;
                                packingDetail.AllJweight = Math.Round((double)(packingDetail.UnitJWeight * packingDetail.InvoiceXOQuantity / packingDetail.UnitNum), 4);
                                packingDetail.AllMWeight = Math.Round((double)(packingDetail.UnitMWeight * packingDetail.InvoiceXOQuantity / packingDetail.UnitNum), 4);
                                packingDetail.AllCaiji   = Math.Round((double)(packingDetail.UnitCaiji * packingDetail.InvoiceXOQuantity / packingDetail.UnitNum), 4);

                                packingDetail.PackingNum = packingDetail.InvoiceXOQuantity == null ? 0 : packingDetail.InvoiceXOQuantity;
                                packingDetail.Amount     = Convert.ToDecimal(packingDetail.PackingNum) * packingDetail.UnitPrice;
                            }
                            else
                            {
                                packingDetail.BoxNum     = Convert.ToInt32(Math.Truncate(Convert.ToDouble(detail.InvoiceXODetailQuantity0 / packingDetail.UnitNum)));
                                packingDetail.AllJweight = packingDetail.UnitJWeight * packingDetail.BoxNum;
                                packingDetail.AllMWeight = packingDetail.UnitMWeight * packingDetail.BoxNum;
                                packingDetail.AllCaiji   = packingDetail.UnitCaiji * packingDetail.BoxNum;

                                packingDetail.PackingNum = (packingDetail.UnitNum * packingDetail.BoxNum) == null ? packingDetail.InvoiceXOQuantity : packingDetail.UnitNum * packingDetail.BoxNum;
                                packingDetail.Amount     = Convert.ToDecimal(packingDetail.PackingNum) * packingDetail.UnitPrice;
                            }
                        }
                        //if (packingDetail.UnitNum == 0 || packingDetail.UnitNum == null)
                        //{
                        //    MessageBox.Show("請設置該產品的成箱數量!\r" + (packingDetail.Product == null ? null : packingDetail.Product), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //    //return;
                        //}
                        //else
                        //{
                        //    packingDetail.BoxNum = (int)(detail.InvoiceXODetailQuantity0 / this.PackingSpecification);
                        //    //packingDetail.HandPackingId = Convert.ToChar(Id).ToString() + " 1" + "-" + packingDetail.BoxNum.ToString();
                        //    packingDetail.PackingNum = this.PackingSpecification * packingDetail.BoxNum;
                        //    packingDetail.AllJweight = packingDetail.UnitJWeight * packingDetail.BoxNum;
                        //    packingDetail.AllMWeight = packingDetail.UnitMWeight * packingDetail.BoxNum;
                        //    packingDetail.AllCaiji = packingDetail.UnitCaiji * packingDetail.BoxNum;
                        //}

                        this._invoicePacking.Details.Add(packingDetail);

                        if (packingDetail.UnitNum > 0 && packingDetail.InvoiceXOQuantity % packingDetail.UnitNum != 0 && packingDetail.UnitNum < packingDetail.InvoiceXOQuantity)
                        {
                            Model.InvoicePackingDetail invoicePackingDetail = new Book.Model.InvoicePackingDetail();
                            //invoicePackingDetail.InvoicePackingDetailId = this._invoicePackingDetailManager.GetId();
                            //this._invoicePackingDetailManager.TiGuiExists(invoicePackingDetail);
                            invoicePackingDetail.InvoicePackingDetailId = Guid.NewGuid().ToString();
                            invoicePackingDetail.InvoicePackingId       = this._invoicePacking.InvoicePackingId;
                            invoicePackingDetail.HandbookId             = detail.HandbookId;
                            invoicePackingDetail.HandbookProductId      = detail.HandbookProductId;
                            invoicePackingDetail.Product           = packingDetail.Product;
                            invoicePackingDetail.ProductId         = packingDetail.ProductId;
                            invoicePackingDetail.Customer          = packingDetail.Customer;
                            invoicePackingDetail.CustomerId        = packingDetail.CustomerId;
                            invoicePackingDetail.XOCustomer        = packingDetail.XOCustomer;
                            invoicePackingDetail.XOCustomerId      = packingDetail.XOCustomerId;
                            invoicePackingDetail.UnitPrice         = packingDetail.UnitPrice;
                            invoicePackingDetail.InvoiceXOQuantity = detail.InvoiceXODetailQuantity0 == null ? 0 : detail.InvoiceXODetailQuantity0;
                            invoicePackingDetail.PackingNum        = invoicePackingDetail.InvoiceXOQuantity % packingDetail.UnitNum;
                            invoicePackingDetail.HasFPQuantity     = 0;
                            invoicePackingDetail.Amount            = Convert.ToDecimal(invoicePackingDetail.PackingNum) * invoicePackingDetail.UnitPrice;
                            invoicePackingDetail.ProductUnit       = packingDetail.ProductUnit;
                            invoicePackingDetail.BoxNum            = 1;
                            invoicePackingDetail.BLong             = packingDetail.BLong;
                            invoicePackingDetail.BWidth            = packingDetail.BWidth;
                            invoicePackingDetail.BHeight           = packingDetail.BHeight;
                            invoicePackingDetail.UnitJWeight       = Math.Round((double)(packingDetail.UnitJWeight * invoicePackingDetail.PackingNum / packingDetail.UnitNum), 4);
                            invoicePackingDetail.UnitMWeight       = Math.Round((double)(packingDetail.UnitMWeight * invoicePackingDetail.PackingNum / packingDetail.UnitNum), 4);
                            invoicePackingDetail.UnitCaiji         = Math.Round((double)(packingDetail.UnitCaiji * invoicePackingDetail.PackingNum / packingDetail.UnitNum), 4);
                            invoicePackingDetail.AllJweight        = invoicePackingDetail.UnitJWeight;
                            invoicePackingDetail.AllMWeight        = invoicePackingDetail.UnitMWeight;
                            invoicePackingDetail.AllCaiji          = invoicePackingDetail.UnitCaiji;
                            invoicePackingDetail.WeightUnit        = "KGS";
                            invoicePackingDetail.PriceUnit         = "USD";
                            invoicePackingDetail.BGHandBookProduct = packingDetail.BGHandBookProduct;

                            this._invoicePacking.Details.Add(invoicePackingDetail);
                        }
                    }
                }
                double amount = 0;
                foreach (var item in this._invoicePacking.Details)
                {
                    amount += Convert.ToDouble(item.Amount);
                }
                this.txt_TotalAmount.Text           = amount.ToString();
                this.bindingSourceDetail.DataSource = _invoicePacking.Details;
                this.gridControl1.RefreshDataSource();
                this.bindingSourceDetail.MoveLast();
            }
        }
        /// <summary>
        /// Insert a CustomerProducts.
        /// </summary>
        public void Insert(Model.CustomerProducts customerProducts)
        {
            this.Validate(customerProducts);

            //if (this.Exists(customerProducts))
            //{
            //    throw new Helper.InvalidValueException(Model.CustomerProducts.PROPERTY_CUSTOMERPRODUCTNAME);
            //}
            try
            {
                BL.V.BeginTransaction();
                //保存后返回第一个ID
                // string primarykeyid =null;
                string customProductName = null;
                // StringBuilder strBU = new StringBuilder();
                customerProducts.CustomerId = customerProducts.Customer.CustomerId;
                customerProducts.InsertTime = DateTime.Now;
                //保存后返回第一个ID
                // primarykeyid = customerProducts.PrimaryKeyId;
                customProductName = customerProducts.CustomerProductName;

                // customerProducts.BuyUnitId = customerProducts.BuyUnit == null ? null : customerProducts.BuyUnit.ProductUnitId;
                customerProducts.DepotId         = customerProducts.Depot == null ? null : customerProducts.Depot.DepotId;
                customerProducts.DepotPositionId = customerProducts.DepotPosition == null ? null : customerProducts.DepotPosition.DepotPositionId;
                //customerProducts.DepotUnitId = customerProducts.DepotUnit == null ? null : customerProducts.DepotUnit.ProductUnitId;
                //// customerProducts.MainUnitId = customerProducts.MainUnit == null ? null : customerProducts.MainUnit.ProductUnitId;
                //customerProducts.ProduceUnitId = customerProducts.ProduceUnit == null ? null : customerProducts.ProduceUnit.ProductUnitId;
                //customerProducts.QualityTestUnitId = customerProducts.QualityTestUnit == null ? null : customerProducts.QualityTestUnit.ProductUnitId;
                //customerProducts.SellUnitId = customerProducts.SellUnit == null ? null : customerProducts.SellUnit.ProductUnitId;
                //customerProducts.UnitGroupId = customerProducts.UnitGroup == null ? null : customerProducts.UnitGroup.UnitGroupId;


                Model.Product product = new Book.Model.Product();// customerProducts.Product;
                product.CustomerBeforeProductId = customerProducts.Product.ProductId;
                product.ProductId = Guid.NewGuid().ToString();



                customerProducts.CustomerProductProceName = product.ProductId;//新产生的商品ID
                //if (IsExistsCustomerProductId(customerProducts.CustomerProductId, customerProducts.PrimaryKeyId))
                //    throw new Helper.InvalidValueException(Model.CustomerProducts.PRO_CustomerProductId + "_Exists");
                //if (SelectByCustomerIdAndProductId(customerProducts.ProductId, null, customerProducts.CustomerId))
                //    throw new Helper.InvalidValueException(Model.CustomerProducts.PRO_CustomerId);
                if (this.Exists(customerProducts))
                {
                    throw new Helper.InvalidValueException(Model.CustomerProducts.PRO_CustomerProductId + "_Exists");
                }

                accessor.Insert(customerProducts);
                //加入商品表

                product.IsCustomerProduct = true;

                //指定客户产品对应产品编号

                product.CustomerBeforeProductName = customerProducts.Product.ProductName;
                //添加的客户产品名稱添加至产品表CustomerProductName 字段
                product.CustomerProductName = customerProducts.CustomerProductId;
                product.Customer            = customerProducts.Customer;
                product.ProductDescription  = customerProducts.CustomerProductDesc;
                if (product.Customer != null)
                {
                    product.CustomerId = product.Customer.CustomerId;
                }
                //byte[] pic = new byte[] { };
                //if (product.ProductImage == null)
                //    product.ProductImage = pic;
                //if (product.ProductImage1 == null)
                //    product.ProductImage1 = pic;
                //if (product.ProductImage2 == null)
                //    product.ProductImage2 = pic;
                //if (product.ProductImage3 == null)
                //    product.ProductImage3 = pic;
                product.XOPriceAndRange = customerProducts.XOPrice;


                product.Id          = customerProducts.Product.Id + "{" + product.CustomerBeforeProductName + "}" + "-" + customerProducts.Version;
                product.ProductName = customerProducts.Product.ProductName;
                //product.ProductCategory = customerProducts.Product.ProductCategory;
                product.ProductCategoryId = customerProducts.Product.ProductCategoryId;
                //    product.BasedUnitGroup = customerProducts.Product.BasedUnitGroup;
                product.BasedUnitGroupId = customerProducts.Product.BasedUnitGroupId;
                //  product.BuyUnit = this.product.BuyUnit;
                product.BuyUnitId = customerProducts.BuyUnitId;
                // product.Depot = this.product.Depot;
                product.DepotId = customerProducts.DepotId;
                // product.DepotUnit = this.product.DepotUnit;
                product.DepotUnitId = customerProducts.DepotUnitId;
                //  product.ProduceUnit = this.product.ProduceUnit;
                product.ProduceUnitId = customerProducts.ProduceUnitId;
                // product.SellUnit = this.product.SellUnit;
                product.SellUnitId = customerProducts.SellUnitId;
                // product.QualityTestUnit = this.product.QualityTestUnit;
                product.QualityTestUnitId = customerProducts.QualityTestUnitId;
                // product.WeightUnitGroup = this.product.WeightUnitGroup;
                product.WeightUnitGroupId = customerProducts.Product.WeightUnitGroupId;
                // product.WeightUnit = this.product.WeightUnit;
                product.WeightUnitId         = customerProducts.Product.WeightUnitId;
                product.HomeMade             = customerProducts.Product.HomeMade;
                product.OutSourcing          = customerProducts.Product.OutSourcing;
                product.TrustOut             = customerProducts.Product.TrustOut;
                product.Consume              = customerProducts.Product.Consume;
                product.ProductBarCodeIsAuto = true;
                //product.ProductBarCode = product.Id;
                product.StocksQuantity     = 0;
                product.OrderOnWayQuantity = 0;
                product.ProductVersion     = customerProducts.Version;
                product.ProductDeadDate    = customerProducts.VersionDate;
                product.EmployeeCreator    = BL.V.ActiveOperator.Employee;
                product.EmployeeCreatorId  = product.EmployeeCreator == null ? null : product.EmployeeCreator.EmployeeId;
                product.InsertTime         = DateTime.Now;

                //商品条码
                product.ProductBarCode = ProductBarCodeSetManager.RandomBarCode();
                ProductManager.BarCodeRecursion(product);
                ProductBarCodeSetManager.Increment();

                productAccessor.Insert(product);

                //自动生成对应的BOM单
                //Model.BomParentPartInfo bom = new Book.Model.BomParentPartInfo();
                //bom.BomId = Guid.NewGuid().ToString();
                //bom.Product = product;
                //bom.ProductId = product.ProductId;
                //bom.Id = new BL.BomParentPartInfoManager().GetId();
                //bom.LossRate = 0;
                //bom.EffectiveDate = DateTime.Now;
                //bom.DefaultQuantity = 1;
                //bom.Status = 0;
                //bom.IsEdit = "*";
                //bom.InsertTime = DateTime.Now;
                //string invoiceKind = "bom".ToLower();
                //string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, bom.InsertTime.Value.Year);
                //string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, bom.InsertTime.Value.Year, bom.InsertTime.Value.Month);
                //string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, bom.InsertTime.Value.ToString("yyyy-MM-dd"));
                //string sequencekey = string.Format(invoiceKind);
                //SequenceManager.Increment(sequencekey_y);
                //SequenceManager.Increment(sequencekey_m);
                //SequenceManager.Increment(sequencekey_d);
                //SequenceManager.Increment(sequencekey);
                //bom.EmployeeAddId = BL.V.ActiveOperator.EmployeeId;

                //bomParentPartInfoAccessor.Insert(bom);

                //客户产品价格
                Model.CustomerProductPrice customerProducrPrice = new Book.Model.CustomerProductPrice();
                customerProducrPrice.CustomerProductPriceId = Guid.NewGuid().ToString();
                customerProducrPrice.CustomerId             = customerProducts.CustomerId;
                customerProducrPrice.ProductId          = product.ProductId;
                customerProducrPrice.InsertTime         = DateTime.Now;
                customerProducrPrice.UpdateTime         = DateTime.Now;
                customerProducrPrice.CustomerProductsId = customerProducts.PrimaryKeyId;
                customerProductPriceAccessor.Insert(customerProducrPrice);

                // customerProductProcessAccessor.Delete(customerProducts);

                //foreach (Model.CustomerProductProcess cpp in customerProducts.CustomerProductProcessList)
                //{
                //   if (cpp.ProcessCategory == null) continue;

                //   strBU.Append(cpp.ProcessCategory.ProcessCategoryName);
                //   cpp.CustomerProductProcessId = Guid.NewGuid().ToString();
                //   cpp.PrimaryKeyId = customerProducts.PrimaryKeyId;
                // //  if (cpp.IsCheck.Value)
                //  // {
                //       cpp.ProcessId = cpp.Process == null ? null : cpp.Process.ProcessId;
                //   //}
                //   //else
                //   //{
                //   //    cpp.ProcessId = null;
                //   //}
                //   cpp.ProcessCategoryId = cpp.ProcessCategory == null ? null : cpp.ProcessCategory.ProcessCategoryId;
                //   customerProductProcessAccessor.Insert(cpp);
                // }
                //   foreach (Model.CustomerProductsBom bom in customerProducts.CustomerProductsBomInfos)
                //  {
                //      if (bom != null)
                //       {
                //           bom.PriamryKeyId = Guid.NewGuid().ToString();
                //           if (bom.Product != null)
                //               bom.ProductId = bom.Product.ProductId;
                //           bom.PrimaryKeyId = customerProducts.PrimaryKeyId;
                //           customerProductsBomAccessor.Insert(bom);
                //       }
                //   }

                //   if (customerProducts.PackageCustomerDetails!=null)
                //   {
                //       foreach (Model.PackageCustomerDetails pac in customerProducts.PackageCustomerDetails)
                //       {
                //           if (pac != null)
                //           {
                //               pac.PackageCustomerDetailsId = Guid.NewGuid().ToString();
                //               pac.PrimaryKeyId = customerProducts.CustomerProductId;
                //               packageCustomerDetailsAccessor.Insert(pac);
                //           }
                //        }
                //   }
                /////////////////////////////////  //加工后名称添加
                //加工后名称添加
                //if (strBU.Length!= 0 )
                //{
                //    customerProducts.PrimaryKeyId = Guid.NewGuid().ToString();

                // //   customerProductProcessAccessor.Delete(customerProducts);


                //    customerProducts.CustomerProductName +=strBU.ToString();
                //    accessor.Insert(customerProducts);
                //    foreach (Model.CustomerProductProcess cpp in customerProducts.CustomerProductProcessList)
                //    {
                //        if (cpp.ProcessCategory == null) continue;
                //        strBU.Append(customerProducts.CustomerProductName);
                //        cpp.CustomerProductProcessId = Guid.NewGuid().ToString();
                //        cpp.PrimaryKeyId = customerProducts.PrimaryKeyId;
                //        //  if (cpp.IsCheck.Value)
                //        // {
                //        cpp.ProcessId = cpp.Process == null ? null : cpp.Process.ProcessId;
                //        //}
                //        //else
                //        //{
                //        //    cpp.ProcessId = null;
                //        //}
                //        cpp.ProcessCategoryId = cpp.ProcessCategory == null ? null : cpp.ProcessCategory.ProcessCategoryId;
                //        customerProductProcessAccessor.Insert(cpp);
                //    }


                //foreach (Model.CustomerProductsBom bom in customerProducts.CustomerProductsBomInfos)
                //{
                //    if (bom != null)
                //    {
                //        bom.PriamryKeyId = Guid.NewGuid().ToString();
                //        if (bom.Product != null)
                //            bom.ProductId = bom.Product.ProductId;
                //        bom.PrimaryKeyId = customerProducts.PrimaryKeyId;
                //        customerProductsBomAccessor.Insert(bom);
                //    }
                //}
                //if (customerProducts.PackageCustomerDetails.Count!= 0)
                //{
                //    foreach (Model.PackageCustomerDetails pac in customerProducts.PackageCustomerDetails)
                //    {
                //        if (pac != null)
                //        {
                //            pac.PackageCustomerDetailsId = Guid.NewGuid().ToString();
                //            pac.PrimaryKeyId = customerProducts.CustomerProductId;
                //            packageCustomerDetailsAccessor.Insert(pac);
                //        }
                //    }
                //}
                //    customerProducts.PrimaryKeyId = primarykeyid;
                //     customerProducts.CustomerProductName =customProductName;
                //}

                BL.V.CommitTransaction();
            }
            catch
            {
                BL.V.RollbackTransaction();
                throw;
            }
        }
 public void Delete(Model.CustomerProducts custeomerProduct)
 {
     accessor.Delete(custeomerProduct);
 }
 public Model.CustomerProducts GetNext(Model.CustomerProducts e)
 {
     return(sqlmapper.QueryForObject <Model.CustomerProducts>("CustomerProducts.get_next", e));
 }
 public Model.CustomerProducts GetPrev(Model.CustomerProducts e)
 {
     return(sqlmapper.QueryForObject <Model.CustomerProducts>("CustomerProducts.get_prev", e));
 }
示例#19
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);
            }
        }
 public Model.CustomerProducts GetNext(Model.CustomerProducts e)
 {
     return(accessor.GetNext(e));
 }
 public Model.CustomerProducts GetPrev(Model.CustomerProducts e)
 {
     return(accessor.GetPrev(e));
 }
 public bool HasRowsAfter(Model.CustomerProducts e)
 {
     return(accessor.HasRowsAfter(e));
 }
 public bool HasRowsAfter(Model.CustomerProducts e)
 {
     return(sqlmapper.QueryForObject <bool>("CustomerProducts.has_rows_after", e));
 }
示例#24
0
        /// <summary>
        /// Update a CustomerProducts.
        /// </summary>
        public void Update(Model.CustomerProducts customerProducts)
        {
            //
            // todo: add other logic here.
            //
            this.Validate(customerProducts);
            //if (this.ExistsExcept(customerProducts))
            //{
            //    throw new Helper.InvalidValueException(Model.CustomerProducts.PRO_CustomerProductId);
            //}
            try
            {
                BL.V.BeginTransaction();
                // StringBuilder strBU = new StringBuilder();
                customerProducts.UpdateTime = DateTime.Now;
                customerProducts.CustomerId = customerProducts.Customer.CustomerId;
                // customerProducts.BuyUnitId = customerProducts.BuyUnit == null ? null : customerProducts.BuyUnit.ProductUnitId;
                customerProducts.DepotId         = customerProducts.Depot == null ? null : customerProducts.Depot.DepotId;
                customerProducts.DepotPositionId = customerProducts.DepotPosition == null ? null : customerProducts.DepotPosition.DepotPositionId;
                //customerProducts.DepotUnitId = customerProducts.DepotUnit == null ? null : customerProducts.DepotUnit.ProductUnitId;
                //customerProducts.MainUnitId = customerProducts.MainUnit == null ? null : customerProducts.MainUnit.ProductUnitId;
                //customerProducts.ProduceUnitId = customerProducts.ProduceUnit == null ? null : customerProducts.ProduceUnit.ProductUnitId;
                //customerProducts.QualityTestUnitId = customerProducts.QualityTestUnit == null ? null : customerProducts.QualityTestUnit.ProductUnitId;
                //customerProducts.SellUnitId = customerProducts.SellUnit == null ? null : customerProducts.SellUnit.ProductUnitId;
                //customerProducts.UnitGroupId = customerProducts.UnitGroup == null ? null : customerProducts.UnitGroup.UnitGroupId;

                //if (IsExistsCustomerProductId(customerProducts.CustomerProductId, customerProducts.PrimaryKeyId))
                //    throw new Helper.InvalidValueException(Model.CustomerProducts.PRO_CustomerProductId);
                ////if (SelectByCustomerIdAndProductId(customerProducts.ProductId, customerProducts.PrimaryKeyId, customerProducts.CustomerId))
                //    throw new Helper.InvalidValueException(Model.CustomerProducts.PRO_CustomerId);

                if (this.Exists(customerProducts))
                {
                    throw new Helper.InvalidValueException(Model.CustomerProducts.PRO_CustomerProductId + "_Exists");
                }

                accessor.Update(customerProducts);

                //修改商品
                Model.Product product = productAccessor.Get(customerProducts.CustomerProductProceName);

                //指定客户产品对应产品编号
                product.CustomerBeforeProductId   = customerProducts.Product.ProductId;
                product.CustomerBeforeProductName = customerProducts.Product.ProductName;
                product.ProductName = customerProducts.Product.ProductName;
                //添加的客户产品名稱添加至产品表CustomerProductName 字段
                product.CustomerProductName = customerProducts.CustomerProductId;
                product.Customer            = customerProducts.Customer;
                product.ProductDescription  = customerProducts.CustomerProductDesc;
                product.ProductVersion      = customerProducts.Version;
                product.ProductDeadDate     = customerProducts.VersionDate;

                product.BasedUnitGroupId  = customerProducts.UnitGroupId;
                product.BuyUnitId         = customerProducts.BuyUnitId;
                product.SellUnitId        = customerProducts.SellUnitId;
                product.DepotUnitId       = customerProducts.DepotUnitId;
                product.ProduceUnitId     = customerProducts.ProduceUnitId;
                product.QualityTestUnitId = customerProducts.QualityTestUnitId;


                if (product.Customer != null)
                {
                    product.CustomerId = product.Customer.CustomerId;
                }
                //byte[] pic = new byte[] { };
                //if (product.ProductImage == null)
                //    product.ProductImage = pic;
                //if (product.ProductImage1 == null)
                //    product.ProductImage1 = pic;
                //if (product.ProductImage2 == null)
                //    product.ProductImage2 = pic;
                //if (product.ProductImage3 == null)
                //    product.ProductImage3 = pic;

                product.XOPriceAndRange = customerProducts.XOPrice;
                productAccessor.Update(product);

                //客户产品价格
                Model.CustomerProductPrice customerProducrPrice = new Book.Model.CustomerProductPrice();
                customerProducrPrice.CustomerId = customerProducts.CustomerId;
                //customerProducrPrice.ProductId = customerProducts.ProductId;
                customerProducrPrice.UpdateTime         = DateTime.Now;
                customerProducrPrice.CustomerProductsId = customerProducts.PrimaryKeyId;
                customerProductPriceAccessor.UpdateByCustomerProductsId(customerProducrPrice);



                //customerProductProcessAccessor.Delete(customerProducts);
                //customerProductsBomAccessor.Delete(customerProducts);
                //包装
                //packageCustomerDetailsAccessor.Delete(customerProducts);
                //foreach (Model.CustomerProductProcess cpp in customerProducts.CustomerProductProcessList)
                //{
                //    if (cpp.ProcessCategory == null) continue;
                //    strBU.Append(cpp.ProcessCategory.ProcessCategoryName) ;
                //    cpp.CustomerProductProcessId = Guid.NewGuid().ToString();
                //    cpp.PrimaryKeyId = customerProducts.PrimaryKeyId;
                //    //if (cpp.IsCheck.Value)
                //    //{
                //        cpp.ProcessId = cpp.Process == null ? null : cpp.Process.ProcessId;
                //    //}
                //    //else
                //    //{
                //    //    cpp.ProcessId = null;
                //    //}
                //    cpp.ProcessCategoryId = cpp.ProcessCategory == null ? null : cpp.ProcessCategory.ProcessCategoryId;
                //    customerProductProcessAccessor.Insert(cpp);
                //}

                //foreach (Model.CustomerProductsBom bom in customerProducts.CustomerProductsBomInfos)
                //{
                //    bom.PriamryKeyId = Guid.NewGuid().ToString();
                //    bom.ProductId = bom.Product.ProductId;
                //    bom.PrimaryKeyId = customerProducts.PrimaryKeyId;
                //    customerProductsBomAccessor.Insert(bom);
                //}
                //foreach (Model.PackageCustomerDetails pac in customerProducts.PackageCustomerDetails)
                //{
                //    pac.PackageCustomerDetailsId = Guid.NewGuid().ToString();
                //    pac.PrimaryKeyId = customerProducts.CustomerProductId;
                //    packageCustomerDetailsAccessor.Insert(pac);
                //}
                /////////////////////////////////  //加工后名称添加
                //加工后名称添加
                //if (strBU != null)
                //{
                //    customerProducts.PrimaryKeyId = Guid.NewGuid().ToString();
                //    customerProducts.CustomerProductName = strBU.ToString();
                //    accessor.Insert(customerProducts);
                //    foreach (Model.CustomerProductProcess cpp in customerProducts.CustomerProductProcessList)
                //    {
                //        if (cpp.ProcessCategory == null) continue;
                //        strBU.Append(customerProducts.CustomerProductName);
                //        cpp.CustomerProductProcessId = Guid.NewGuid().ToString();
                //        cpp.PrimaryKeyId = customerProducts.PrimaryKeyId;
                //        //  if (cpp.IsCheck.Value)
                //        // {
                //        cpp.ProcessId = cpp.Process == null ? null : cpp.Process.ProcessId;
                //        //}
                //        //else
                //        //{
                //        //    cpp.ProcessId = null;
                //        //}
                //        cpp.ProcessCategoryId = cpp.ProcessCategory == null ? null : cpp.ProcessCategory.ProcessCategoryId;
                //        customerProductProcessAccessor.Insert(cpp);
                //    }
                //    foreach (Model.CustomerProductsBom bom in customerProducts.CustomerProductsBomInfos)
                //    {
                //        if (bom != null)
                //        {
                //            bom.PriamryKeyId = Guid.NewGuid().ToString();
                //            if (bom.Product != null)
                //                bom.ProductId = bom.Product.ProductId;
                //            bom.PrimaryKeyId = customerProducts.PrimaryKeyId;
                //            customerProductsBomAccessor.Insert(bom);
                //        }
                //    }
                //    if (customerProducts.PackageCustomerDetails != null)
                //    {
                //        foreach (Model.PackageCustomerDetails pac in customerProducts.PackageCustomerDetails)
                //        {
                //            if (pac != null)
                //            {
                //                pac.PackageCustomerDetailsId = Guid.NewGuid().ToString();
                //                pac.PrimaryKeyId = customerProducts.CustomerProductId;
                //                packageCustomerDetailsAccessor.Insert(pac);
                //            }
                //        }
                //    }
                //}
                BL.V.CommitTransaction();
            }
            catch
            {
                BL.V.RollbackTransaction();
                throw;
            }
        }
示例#25
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();
            }
        }
示例#26
0
        private void repositoryItemSpinEdit1_EditValueChanged(object sender, EventArgs e)
        {
            Model.InvoiceZX        invoicezx = bindingSourceXO.Current as Model.InvoiceZX;
            Model.CustomerProducts cp        = null;
            //成箱数量
            double?PackingSpecification = 0.0;

            if (invoicezx.Product != null && !(string.IsNullOrEmpty(invoicezx.Product.CustomerProductName) && string.IsNullOrEmpty(invoicezx.Product.CustomerId)))
            {
                cp = new BL.CustomerProductsManager().SelectByCustomerProductProceId(invoicezx.ProductId);
                PackingSpecification = cp.PackingSpecification;
            }
            if (PackingSpecification == 0 || PackingSpecification == null)
            {
                MessageBox.Show("請設置成箱數量!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            SpinEdit spe = sender as SpinEdit;

            if (spe != null)
            {
                invoicezx.ProductNum = Convert.ToDouble(spe.Value.ToString());
            }
            else
            {
                invoicezx.ProductNum = ((sender as BindingSource).Current as Model.InvoiceZX).ProductNum;
            }
            int BoxNum    = (int)(invoicezx.ProductNum / PackingSpecification);
            int detailnum = 0;


            while (this.RInvoiceZXList != null && this.RInvoiceZXList.Where(d => d.ParentInvoceZXId == invoicezx.InvoiceZXId && string.IsNullOrEmpty(d.PackingId) && string.IsNullOrEmpty(d.InvoiceDate.ToString())).ToList <Model.InvoiceZX>().Count > 0)
            {
                this.RInvoiceZXList.Remove(this.RInvoiceZXList.Where(d => d.ParentInvoceZXId == invoicezx.InvoiceZXId && string.IsNullOrEmpty(d.PackingId) && string.IsNullOrEmpty(d.InvoiceDate.ToString())).ToList <Model.InvoiceZX>().Last <Model.InvoiceZX>());
            }

            foreach (Model.InvoiceZX detail in RInvoiceZXList)
            {
                if (detail.ParentInvoceZXId == invoicezx.InvoiceZXId && (!string.IsNullOrEmpty(detail.PackingId) || !string.IsNullOrEmpty(detail.InvoiceDate.ToString())))
                {
                    detailnum += 1;
                }
            }


            if (invoicezx.ProductNum % PackingSpecification == 0)
            {
                DetailAdd(invoicezx, BoxNum, detailnum, cp);
                invoicezx.BoxNum = BoxNum;
            }
            else
            {
                DetailAdd(invoicezx, BoxNum + 1, detailnum, cp);
                invoicezx.BoxNum = BoxNum + 1;
            }

            foreach (Model.InvoiceZX iz in RInvoiceZXList)
            {
                iz.Sequence = (RInvoiceZXList.IndexOf(iz) + 1).ToString();
            }
            this.bindingSourceDetail.DataSource = RInvoiceZXList;
            this.gridControl5.RefreshDataSource();
            this.gridControl6.RefreshDataSource();
        }
 public bool HasRowsBefore(Model.CustomerProducts e)
 {
     return(accessor.HasRowsBefore(e));
 }
 public bool HasRowsBefore(Model.CustomerProducts e)
 {
     return(sqlmapper.QueryForObject <bool>("CustomerProducts.has_rows_before", e));
 }
示例#29
0
        /// <summary>
        /// Insert a CustomerProducts.
        /// </summary>
        public void Insert(Model.CustomerProducts customerProducts)
        {
            this.Validate(customerProducts);

            //if (this.Exists(customerProducts))
            //{
            //    throw new Helper.InvalidValueException(Model.CustomerProducts.PROPERTY_CUSTOMERPRODUCTNAME);
            //}
            try
            {
                BL.V.BeginTransaction();
                //保存后返回第一个ID
                // string primarykeyid =null;
                string customProductName = null;
                // StringBuilder strBU = new StringBuilder();
                customerProducts.CustomerId = customerProducts.Customer.CustomerId;
                customerProducts.InsertTime = DateTime.Now;
                //保存后返回第一个ID
                // primarykeyid = customerProducts.PrimaryKeyId;
                customProductName = customerProducts.CustomerProductName;

                // customerProducts.BuyUnitId = customerProducts.BuyUnit == null ? null : customerProducts.BuyUnit.ProductUnitId;
                customerProducts.DepotId         = customerProducts.Depot == null ? null : customerProducts.Depot.DepotId;
                customerProducts.DepotPositionId = customerProducts.DepotPosition == null ? null : customerProducts.DepotPosition.DepotPositionId;
                //customerProducts.DepotUnitId = customerProducts.DepotUnit == null ? null : customerProducts.DepotUnit.ProductUnitId;
                //// customerProducts.MainUnitId = customerProducts.MainUnit == null ? null : customerProducts.MainUnit.ProductUnitId;
                //customerProducts.ProduceUnitId = customerProducts.ProduceUnit == null ? null : customerProducts.ProduceUnit.ProductUnitId;
                //customerProducts.QualityTestUnitId = customerProducts.QualityTestUnit == null ? null : customerProducts.QualityTestUnit.ProductUnitId;
                //customerProducts.SellUnitId = customerProducts.SellUnit == null ? null : customerProducts.SellUnit.ProductUnitId;
                //customerProducts.UnitGroupId = customerProducts.UnitGroup == null ? null : customerProducts.UnitGroup.UnitGroupId;


                Model.Product product = new Book.Model.Product();// customerProducts.Product;
                product.CustomerBeforeProductId = customerProducts.Product.ProductId;
                product.ProductId = Guid.NewGuid().ToString();



                customerProducts.CustomerProductProceName = product.ProductId;//新产生的商品ID
                //if (IsExistsCustomerProductId(customerProducts.CustomerProductId, customerProducts.PrimaryKeyId))
                //    throw new Helper.InvalidValueException(Model.CustomerProducts.PRO_CustomerProductId + "_Exists");
                //if (SelectByCustomerIdAndProductId(customerProducts.ProductId, null, customerProducts.CustomerId))
                //    throw new Helper.InvalidValueException(Model.CustomerProducts.PRO_CustomerId);
                if (this.Exists(customerProducts))
                {
                    throw new Helper.InvalidValueException(Model.CustomerProducts.PRO_CustomerProductId + "_Exists");
                }

                accessor.Insert(customerProducts);
                //加入商品表

                product.IsCustomerProduct = true;

                //指定客户产品对应产品编号

                product.CustomerBeforeProductName = customerProducts.Product.ProductName;
                //添加的客户产品名稱添加至产品表CustomerProductName 字段
                product.CustomerProductName = customerProducts.CustomerProductId;
                product.Customer            = customerProducts.Customer;
                product.ProductDescription  = customerProducts.CustomerProductDesc;
                if (product.Customer != null)
                {
                    product.CustomerId = product.Customer.CustomerId;
                }
                //byte[] pic = new byte[] { };
                //if (product.ProductImage == null)
                //    product.ProductImage = pic;
                //if (product.ProductImage1 == null)
                //    product.ProductImage1 = pic;
                //if (product.ProductImage2 == null)
                //    product.ProductImage2 = pic;
                //if (product.ProductImage3 == null)
                //    product.ProductImage3 = pic;
                product.XOPriceAndRange = customerProducts.XOPrice;


                product.Id          = customerProducts.Product.Id + "{" + product.CustomerBeforeProductName + "}" + "-" + customerProducts.Version;
                product.ProductName = customerProducts.Product.ProductName;
                //product.ProductCategory = customerProducts.Product.ProductCategory;
                product.ProductCategoryId = customerProducts.Product.ProductCategoryId;
                //    product.BasedUnitGroup = customerProducts.Product.BasedUnitGroup;
                product.BasedUnitGroupId = customerProducts.Product.BasedUnitGroupId;
                //  product.BuyUnit = this.product.BuyUnit;
                product.BuyUnitId = customerProducts.BuyUnitId;
                // product.Depot = this.product.Depot;
                product.DepotId = customerProducts.DepotId;
                // product.DepotUnit = this.product.DepotUnit;
                product.DepotUnitId = customerProducts.DepotUnitId;
                //  product.ProduceUnit = this.product.ProduceUnit;
                product.ProduceUnitId = customerProducts.ProduceUnitId;
                // product.SellUnit = this.product.SellUnit;
                product.SellUnitId = customerProducts.SellUnitId;
                // product.QualityTestUnit = this.product.QualityTestUnit;
                product.QualityTestUnitId = customerProducts.QualityTestUnitId;
                // product.WeightUnitGroup = this.product.WeightUnitGroup;
                product.WeightUnitGroupId = customerProducts.Product.WeightUnitGroupId;
                // product.WeightUnit = this.product.WeightUnit;
                product.WeightUnitId         = customerProducts.Product.WeightUnitId;
                product.HomeMade             = customerProducts.Product.HomeMade;
                product.OutSourcing          = customerProducts.Product.OutSourcing;
                product.TrustOut             = customerProducts.Product.TrustOut;
                product.Consume              = customerProducts.Product.Consume;
                product.ProductBarCodeIsAuto = true;
                product.ProductBarCode       = product.Id;
                product.StocksQuantity       = 0;
                product.OrderOnWayQuantity   = 0;
                product.ProductVersion       = customerProducts.Version;
                product.ProductDeadDate      = customerProducts.VersionDate;
                product.ProduceCounty        = customerProducts.Product.ProduceCounty;
                productAccessor.Insert(product);

                //客户产品价格
                Model.CustomerProductPrice customerProducrPrice = new Book.Model.CustomerProductPrice();
                customerProducrPrice.CustomerProductPriceId = Guid.NewGuid().ToString();
                customerProducrPrice.CustomerId             = customerProducts.CustomerId;
                customerProducrPrice.ProductId          = product.ProductId;
                customerProducrPrice.InsertTime         = DateTime.Now;
                customerProducrPrice.UpdateTime         = DateTime.Now;
                customerProducrPrice.CustomerProductsId = customerProducts.PrimaryKeyId;
                customerProductPriceAccessor.Insert(customerProducrPrice);
                product.QualityTestUnitId = customerProducts.QualityTestUnitId;
                // customerProductProcessAccessor.Delete(customerProducts);

                //foreach (Model.CustomerProductProcess cpp in customerProducts.CustomerProductProcessList)
                //{
                //   if (cpp.ProcessCategory == null) continue;

                //   strBU.Append(cpp.ProcessCategory.ProcessCategoryName);
                //   cpp.CustomerProductProcessId = Guid.NewGuid().ToString();
                //   cpp.PrimaryKeyId = customerProducts.PrimaryKeyId;
                // //  if (cpp.IsCheck.Value)
                //  // {
                //       cpp.ProcessId = cpp.Process == null ? null : cpp.Process.ProcessId;
                //   //}
                //   //else
                //   //{
                //   //    cpp.ProcessId = null;
                //   //}
                //   cpp.ProcessCategoryId = cpp.ProcessCategory == null ? null : cpp.ProcessCategory.ProcessCategoryId;
                //   customerProductProcessAccessor.Insert(cpp);
                // }
                //   foreach (Model.CustomerProductsBom bom in customerProducts.CustomerProductsBomInfos)
                //  {
                //      if (bom != null)
                //       {
                //           bom.PriamryKeyId = Guid.NewGuid().ToString();
                //           if (bom.Product != null)
                //               bom.ProductId = bom.Product.ProductId;
                //           bom.PrimaryKeyId = customerProducts.PrimaryKeyId;
                //           customerProductsBomAccessor.Insert(bom);
                //       }
                //   }

                //   if (customerProducts.PackageCustomerDetails!=null)
                //   {
                //       foreach (Model.PackageCustomerDetails pac in customerProducts.PackageCustomerDetails)
                //       {
                //           if (pac != null)
                //           {
                //               pac.PackageCustomerDetailsId = Guid.NewGuid().ToString();
                //               pac.PrimaryKeyId = customerProducts.CustomerProductId;
                //               packageCustomerDetailsAccessor.Insert(pac);
                //           }
                //        }
                //   }
                /////////////////////////////////  //加工后名称添加
                //加工后名称添加
                //if (strBU.Length!= 0 )
                //{
                //    customerProducts.PrimaryKeyId = Guid.NewGuid().ToString();

                // //   customerProductProcessAccessor.Delete(customerProducts);


                //    customerProducts.CustomerProductName +=strBU.ToString();
                //    accessor.Insert(customerProducts);
                //    foreach (Model.CustomerProductProcess cpp in customerProducts.CustomerProductProcessList)
                //    {
                //        if (cpp.ProcessCategory == null) continue;
                //        strBU.Append(customerProducts.CustomerProductName);
                //        cpp.CustomerProductProcessId = Guid.NewGuid().ToString();
                //        cpp.PrimaryKeyId = customerProducts.PrimaryKeyId;
                //        //  if (cpp.IsCheck.Value)
                //        // {
                //        cpp.ProcessId = cpp.Process == null ? null : cpp.Process.ProcessId;
                //        //}
                //        //else
                //        //{
                //        //    cpp.ProcessId = null;
                //        //}
                //        cpp.ProcessCategoryId = cpp.ProcessCategory == null ? null : cpp.ProcessCategory.ProcessCategoryId;
                //        customerProductProcessAccessor.Insert(cpp);
                //    }


                //foreach (Model.CustomerProductsBom bom in customerProducts.CustomerProductsBomInfos)
                //{
                //    if (bom != null)
                //    {
                //        bom.PriamryKeyId = Guid.NewGuid().ToString();
                //        if (bom.Product != null)
                //            bom.ProductId = bom.Product.ProductId;
                //        bom.PrimaryKeyId = customerProducts.PrimaryKeyId;
                //        customerProductsBomAccessor.Insert(bom);
                //    }
                //}
                //if (customerProducts.PackageCustomerDetails.Count!= 0)
                //{
                //    foreach (Model.PackageCustomerDetails pac in customerProducts.PackageCustomerDetails)
                //    {
                //        if (pac != null)
                //        {
                //            pac.PackageCustomerDetailsId = Guid.NewGuid().ToString();
                //            pac.PrimaryKeyId = customerProducts.CustomerProductId;
                //            packageCustomerDetailsAccessor.Insert(pac);
                //        }
                //    }
                //}
                //    customerProducts.PrimaryKeyId = primarykeyid;
                //     customerProducts.CustomerProductName =customProductName;
                //}

                BL.V.CommitTransaction();
            }
            catch
            {
                BL.V.RollbackTransaction();
                throw;
            }
        }
 public void Insert(Model.CustomerProducts e)
 {
     this.Insert <Model.CustomerProducts>(e);
 }