예제 #1
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            StockEditorChooseForm f = new StockEditorChooseForm();

            if (f.ShowDialog() == DialogResult.OK)
            {
                this._stockEditor = f.SelectedItem as Model.StockEditor;


                this.lookUpEditDepot.EditValue   = this._stockEditor.DepotId;
                this.lookUpEditProCate.EditValue = this._stockEditor.ProductCategoryId;
                this._stockCheck.StockEditorId   = this._stockEditor.StockEditorId;
                foreach (Model.StockEditorDetal editDetail in new BL.StockEditorDetalManager().SelectByStockEditorId(this._stockEditor.StockEditorId))
                {
                    Model.StockCheckDetail detail = new Book.Model.StockCheckDetail();
                    detail.StockCheckDetailId     = Guid.NewGuid().ToString();
                    detail.Product                = editDetail.Product;
                    detail.ProductId              = editDetail.ProductId;
                    detail.ProductUnitName        = editDetail.ProductUnitName;
                    detail.StockCheck             = this._stockCheck;
                    detail.StockCheckId           = this._stockCheck.StockCheckId;
                    detail.StockCheckQuantity     = editDetail.StockEditorQuantity;
                    detail.StockCheckBookQuantity = this.stockManager.GetStockByProductIdAndDepotPositionId(editDetail.ProductId, editDetail.DepotPositionId) == null ? 0 : this.stockManager.GetStockByProductIdAndDepotPositionId(editDetail.ProductId, editDetail.DepotPositionId).StockQuantity1;
                    detail.DepotPosition          = editDetail.DepotPosition;
                    detail.DepotPositionId        = editDetail.DepotPositionId;
                    detail.Directions             = editDetail.Directions;
                    this._stockCheck.Details.Add(detail);
                    this.gridControl1.RefreshDataSource();
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Update a StockEditor.
        /// </summary>
        public void Update(Model.StockEditor stockEditor)
        {
            try
            {
                BL.V.BeginTransaction();

                accessor.Update(stockEditor);

                foreach (Model.StockEditorDetal stockEditorDetail in stockEditor.ProductPositionNums)
                {
                    Model.StockEditorDetal temp = stockEditorDetailsAccessor.Get(stockEditorDetail.StockEditorDetalId);
                    if (temp != null)
                    {
                        stockEditorDetailsAccessor.Update(stockEditorDetail);
                    }
                    else
                    {
                        stockEditorDetailsAccessor.Insert(stockEditorDetail);
                    }
                }

                BL.V.CommitTransaction();
            }
            catch
            {
                BL.V.RollbackTransaction();
                throw;
            }
        }
예제 #3
0
        /// <summary>
        /// Insert a StockEditor.
        /// </summary>
        public void Insert(Model.StockEditor stockEditor)
        {
            try
            {
                BL.V.BeginTransaction();
                stockEditor.InsertTime = DateTime.Now;
                TiGuiExists(stockEditor);
                stockEditor.UpdateTime = DateTime.Now;
                string invoiceKind   = this.GetInvoiceKind().ToLower();
                string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, stockEditor.InsertTime.Value.Year);
                string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, stockEditor.InsertTime.Value.Year, stockEditor.InsertTime.Value.Month);
                string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, stockEditor.InsertTime.Value.ToString("yyyy-MM-dd"));
                string sequencekey   = invoiceKind;

                SequenceManager.Increment(sequencekey_y);
                SequenceManager.Increment(sequencekey_m);
                SequenceManager.Increment(sequencekey_d);
                SequenceManager.Increment(sequencekey);
                accessor.Insert(stockEditor);

                foreach (Model.StockEditorDetal stockEditorDetail in stockEditor.ProductPositionNums)
                {
                    stockEditorDetail.StockEditorId = stockEditor.StockEditorId;
                    stockEditorDetailsAccessor.Insert(stockEditorDetail);
                }

                BL.V.CommitTransaction();
            }
            catch
            {
                BL.V.RollbackTransaction();
                throw;
            }
        }
예제 #4
0
 public Model.StockEditor GetDetails(Model.StockEditor stockEditor)
 {
     stockEditor = this.Get(stockEditor.StockEditorId);
     if (stockEditor != null)
     {
         stockEditor.Details = stockEditorDetailsAccessor.SelectByStockEditorId(stockEditor.StockEditorId);
     }
     return(stockEditor);
 }
예제 #5
0
        protected override void MovePrev()
        {
            Model.StockEditor stockEditor = this._stockEditorManager.GetPrev(_stockEditor);
            if (stockEditor == null)
            {
                throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows);
            }

            _stockEditor = this._stockEditorManager.Get(stockEditor.StockEditorId);
        }
예제 #6
0
 private void TiGuiExists(Model.StockEditor model)
 {
     if (this.ExistsPrimary(model.StockEditorId))
     {
         //设置KEY值
         string invoiceKind   = this.GetInvoiceKind().ToLower();
         string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, model.InsertTime.Value.Year);
         string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, model.InsertTime.Value.Year, model.InsertTime.Value.Month);
         string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, model.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);
         model.StockEditorId = this.GetId(model.InsertTime.Value);
         TiGuiExists(model);
         //throw new Helper.InvalidValueException(Model.Product.PRO_Id);
     }
 }
예제 #7
0
 public void Delete(Model.StockCheck StockCheck)
 {
     foreach (Model.StockCheckDetail item in StockCheck.Details)
     {
         Model.Stock stock = new Book.Model.Stock();
         stock = stockManager.GetStockByProductIdAndDepotPositionId(item.ProductId, item.DepotPositionId);
         if (stock != null)
         {
             stock.StockQuantity1 = (stock.StockQuantity1 == null ? 0 : stock.StockQuantity1) + (item.StockCheckQuantityDiff == null ? 0 : item.StockCheckQuantityDiff);
             stock.IsNotUpdate    = true;
             stockManager.Update(stock);
         }
         productmanager.UpdateProduct_Stock(item.Product);
     }
     accessor.Delete(StockCheck.StockCheckId);
     Model.StockEditor stockEditor = stockEditorAccessor.Get(StockCheck.StockEditorId);
     stockEditor.IsStockCheck = false;
     stockEditorAccessor.Update(stockEditor);
 }
예제 #8
0
 protected override void Delete()
 {
     if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
     {
         return;
     }
     try
     {
         this._stockEditorManager.Delete(_stockEditor.StockEditorId);
         _stockEditor = this._stockEditorManager.GetNext(_stockEditor);
         if (_stockEditor == null)
         {
             _stockEditor = this._stockEditorManager.GetLast();
         }
     }
     catch
     {
         throw;
     }
 }
예제 #9
0
 public StockEditorReport(Model.StockEditor stockEditor)
 {
     InitializeComponent();
     this.xrLabelReportName.Text        = BL.Settings.CompanyChineseName;
     this.xrLabelTitleName.Text         = Properties.Resources.StockEditor;
     this.xrLabelStockEditorId.Text     = stockEditor.StockEditorId;
     this.xrLabelStockEditorDate.Text   = stockEditor.StockEditorDate.Value.ToString("yyyy-MM-dd");
     this.xrLabelProductCategoryId.Text = this.productCategoryManager.Get(stockEditor.ProductCategoryId).ProductCategoryName;
     //this.xrLabelEmployeeId.Text = stockEditor.Employee == null ? "" : stockEditor.Employee.EmployeeName;
     this.xrLabelEmployee0Id.Text = stockEditor.Employee0 == null ? "" : stockEditor.Employee0.EmployeeName;
     this.xrLabelDirections.Text  = stockEditor.Directions;
     this.xrLabelDepotId.Text     = stockEditor.Depot == null?"":stockEditor.Depot.ToString();
     System.Collections.Generic.IList <Model.StockEditorDetal> list = this.stockEditorDetailManager.SelectByStockEditorId(stockEditor.StockEditorId);
     this.DataSource = list;
     this.xrTableCellCustomerProductName.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_CustomerProductName);
     this.xrTableCellDepotPositionId.DataBindings.Add("Text", this.DataSource, "DepotPosition." + Model.DepotPosition.PROPERTY_ID);
     this.xrTableCellDirections.DataBindings.Add("Text", this.DataSource, Model.StockEditorDetal.PROPERTY_DIRECTIONS);
     this.xrTableCellProductId.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_Id);
     this.xrTableCellProductName.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_ProductName);
     this.xrTableCellProductUnitName.DataBindings.Add("Text", this.DataSource, Model.StockEditorDetal.PROPERTY_PRODUCTUNITNAME);
     this.xrTableCellStockEditorQuantity.DataBindings.Add("Text", this.DataSource, Model.StockEditorDetal.PROPERTY_STOCKEDITORQUANTITY);
 }
예제 #10
0
 protected override void AddNew()
 {
     dic.Clear();
     productlist.Clear();
     _stockEditor = null;
 }
예제 #11
0
 protected override void MoveLast()
 {
     _stockEditor = this._stockEditorManager.Get(this._stockEditorManager.GetLast() == null ? "" : this._stockEditorManager.GetLast().StockEditorId);
 }
예제 #12
0
 public bool HasRowsBefore(Model.StockEditor e)
 {
     return(accessor.HasRowsBefore(e));
 }
예제 #13
0
 public Model.StockEditor GetPrev(Model.StockEditor e)
 {
     return(sqlmapper.QueryForObject <Model.StockEditor>("StockEditor.get_prev", e));
 }
예제 #14
0
 public bool HasRowsAfter(Model.StockEditor e)
 {
     return(accessor.HasRowsAfter(e));
 }
예제 #15
0
 public bool HasRowsAfter(Model.StockEditor e)
 {
     return(sqlmapper.QueryForObject <bool>("StockEditor.has_rows_after", e));
 }
예제 #16
0
 public Model.StockEditor GetNext(Model.StockEditor e)
 {
     return(sqlmapper.QueryForObject <Model.StockEditor>("StockEditor.get_next", e));
 }
예제 #17
0
 public bool HasRowsBefore(Model.StockEditor e)
 {
     return(sqlmapper.QueryForObject <bool>("StockEditor.has_rows_before", e));
 }
예제 #18
0
 public void Update(Model.StockEditor e)
 {
     this.Update <Model.StockEditor>(e);
 }
예제 #19
0
 public Model.StockEditor GetPrev(Model.StockEditor e)
 {
     return(accessor.GetPrev(e));
 }
예제 #20
0
        public override void Refresh()
        {
            if (_stockEditor == null)
            {
                _stockEditor = new Model.StockEditor();
                _stockEditor.StockEditorId   = this._stockEditorManager.GetId(DateTime.Now);
                _stockEditor.StockEditorDate = DateTime.Now;
                _stockEditor.Employee0       = BL.V.ActiveOperator.Employee;
                //if (this.cateList.Count != 0)
                //    category = cateList[0];
                _stockEditor.Details = new List <Model.StockEditorDetal>();
                _stockEditor.ProductPositionNums.Clear();
                this.action = "insert";
            }
            else
            {
                _stockEditor.Details.Clear();
                if (this.action == "insert")
                {
                    foreach (Model.Product product in productlist)
                    {
                        Model.StockEditorDetal detail = new Book.Model.StockEditorDetal();
                        detail.StockEditorDetalId = Guid.NewGuid().ToString();
                        detail.StockEditorId      = _stockEditor.StockEditorId;
                        detail.ProductName        = product.ProductName;
                        detail.ProductId          = product.ProductId;
                        detail.Id = product.Id;
                        detail.CustomerProductName = product.CustomerProductName;
                        detail.ProductId           = product.ProductId;
                        detail.DepotPosition       = product.DepotPosition;
                        detail.DepotPositionId     = product.DepotPositionId;
                        detail.ProductDesc         = product.ProductDescription;
                        detail.ProductVersion      = product.ProductVersion;
                        //object nums = this._stockEditorDetailManager.SelectByProductIdAndStockHId(detail.ProductId, detail.StockEditorId);
                        //if (nums != null)
                        //    detail.StockEditorQuantity = Convert.ToDouble(nums);
                        //else
                        detail.StockEditorQuantity = null;
                        detail.DepotPositionId     = product.DepotPositionId;
                        detail.ProductUnitName     = this.productUnitManager.Get(product.DepotUnitId) == null ? null : this.productUnitManager.Get(product.DepotUnitId).CnName;
                        _stockEditor.Details.Add(detail);
                        // this.bindingSourceDetail.Position = this.bindingSourceDetail.IndexOf(detail);
                    }
                }
                else
                {
                    foreach (Model.Product product in productlist)
                    {
                        Model.StockEditorDetal detail = new Book.Model.StockEditorDetal();
                        detail.StockEditorDetalId = Guid.NewGuid().ToString();
                        detail.StockEditorId      = _stockEditor.StockEditorId;
                        detail.ProductName        = product.ProductName;
                        detail.ProductId          = product.ProductId;
                        detail.Id = product.Id;
                        detail.CustomerProductName = product.CustomerProductName;
                        detail.ProductId           = product.ProductId;
                        detail.DepotPosition       = product.DepotPosition;
                        detail.DepotPositionId     = product.DepotPositionId;
                        detail.ProductDesc         = product.ProductDescription;
                        detail.ProductVersion      = product.ProductVersion;
                        object nums = this._stockEditorDetailManager.SelectByProductIdAndStockHId(detail.ProductId, detail.StockEditorId);
                        if (nums != null)
                        {
                            detail.StockEditorQuantity = Convert.ToDouble(nums);
                        }
                        else
                        {
                            detail.StockEditorQuantity = null;
                        }
                        detail.DepotPositionId = product.DepotPositionId;
                        detail.ProductUnitName = this.productUnitManager.Get(product.DepotUnitId) == null ? null : this.productUnitManager.Get(product.DepotUnitId).CnName;
                        _stockEditor.Details.Add(detail);
                    }
                }
            }
            this.memoEditDirections.Text               = _stockEditor.Directions;
            this.textEditStockEditorId.Text            = _stockEditor.StockEditorId;
            this.dateEditStockEditorDate.DateTime      = _stockEditor.StockEditorDate.Value;
            this.newChooseContorlEmployee0Id.EditValue = _stockEditor.Employee0;
            this.newChooseContorlEmployeeId.EditValue  = _stockEditor.Employee;
            //if (_stockEditor.Supplier != null)
            //    this.newChooseContorlSupplier.EditValue = _stockEditor.Supplier;
            //else
            //    this.newChooseContorlSupplier.EditValue = null;

            this.lookUpEditDepotId.EditValue = this._depotManager.Get(_stockEditor.DepotId);
            if (_stockEditor.ProductCategoryId != null)
            {
                this.buttonEditProductCategoryId.EditValue = this._productCategoryManager.Get(_stockEditor.ProductCategoryId);
            }
            else
            {
                this.buttonEditProductCategoryId.EditValue = category;
            }
            this.bindingSourceDetail.DataSource = _stockEditor.Details;
            this.gridControl1.RefreshDataSource();
            base.Refresh();

            switch (this.action)
            {
            case "insert":
            case "update":
                this.gridView1.OptionsBehavior.Editable        = true;
                this.textEditStockEditorId.Properties.ReadOnly = true;
                break;

            case "view":
                this.gridView1.OptionsBehavior.Editable        = false;
                this.textEditStockEditorId.Properties.ReadOnly = true;
                break;
            }
            this.buttonEditProductCategoryId.Properties.ReadOnly = true;
            this.barButtonItem1.Caption = "共" + this.bindingSourceDetail.Count + "項";
        }
예제 #21
0
 public Model.StockEditor GetNext(Model.StockEditor e)
 {
     return(accessor.GetNext(e));
 }
예제 #22
0
        public void Insert(Model.StockCheck stockCheck)
        {
            //
            // todo:add other logic here
            //
            stockCheck.InsertTime = DateTime.Now;
            stockCheck.UpdateTime = DateTime.Now;

            Validate(stockCheck);

            try
            {
                BL.V.BeginTransaction();

                string invoiceKind   = this.GetInvoiceKind().ToLower();
                string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, stockCheck.InsertTime.Value.Year);
                string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, stockCheck.InsertTime.Value.Year, stockCheck.InsertTime.Value.Month);
                string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, stockCheck.InsertTime.Value.ToString("yyyy-MM-dd"));
                string sequencekey   = invoiceKind;
                SequenceManager.Increment(sequencekey_y);
                SequenceManager.Increment(sequencekey_m);
                SequenceManager.Increment(sequencekey_d);
                SequenceManager.Increment(sequencekey);
                //设置盘点录入表为已校正
                Model.StockEditor stockEditor = stockEditorAccessor.Get(stockCheck.StockEditorId);
                stockEditor.IsStockCheck = true;
                stockEditorAccessor.Update(stockEditor);

                accessor.Insert(stockCheck);

                //Dictionary<string, Model.StockCheckDetail> dic = new Dictionary<string, Book.Model.StockCheckDetail>();
                foreach (Model.StockCheckDetail details in stockCheck.Details)
                {
                    if (details.Product == null || string.IsNullOrEmpty(details.Product.ProductId))
                    {
                        continue;
                    }
                    //if (!dic.ContainsKey(details.Product.ProductId))
                    //    dic.Add(details.Product.ProductId, details);

                    stockCheckDetailAccessor.Insert(details);

                    Model.Stock stock = stockManager.GetStockByProductIdAndDepotPositionId(details.ProductId, details.DepotPositionId);
                    if (stock == null)
                    {
                        stock = new Book.Model.Stock();
                        stock.StockCheckDate   = stockCheck.StockCheckDate;
                        stock.StockId          = Guid.NewGuid().ToString();
                        stock.DepotPositionId  = details.DepotPositionId;
                        stock.DepotId          = stockCheck.DepotId;
                        stock.ProductId        = details.ProductId;
                        stock.StockQuantityOld = 0;
                        stock.StockQuantity1   = details.StockCheckQuantity;
                        stock.IsNotUpdate      = true;
                        stockManager.Insert(stock);
                    }
                    else
                    {
                        stock.StockCheckDate   = stockCheck.StockCheckDate;
                        stock.DepotPositionId  = details.DepotPositionId;
                        stock.StockQuantityOld = stock.StockQuantity1 == null ? 0 : stock.StockQuantity1;
                        stock.StockQuantity1   = details.StockCheckQuantity;
                        stock.IsNotUpdate      = true;
                        stockManager.Update(stock);
                    }

                    //  product.StocksQuantity = stockManager.GetTheCount1OfProductByProductId(product, dic[productId].Depot);
                    //details.Product.StocksQuantity = details.StockCheckQuantity;
                    //修改產品
                    //productmanager.UpdateProduct_Stock(details.Product);
                    details.Product.StocksQuantity    = stockManager.GetTheCountByProduct(details.Product);
                    details.Product.LastStockTakeTime = DateTime.Now;
                    productmanager.update(details.Product);
                }

                //foreach (string productId in dic.Keys)
                //{
                //    Model.Product product = productmanager.Get(productId);
                //    if (product.ProductImage == null)
                //        product.ProductImage = new byte[] { };
                //    if (product.ProductImage1 == null)
                //        product.ProductImage1 = new byte[] { };
                //    if (product.ProductImage2 == null)
                //        product.ProductImage2 = new byte[] { };
                //    if (product.ProductImage3 == null)
                //        product.ProductImage3 = new byte[] { };
                //  //  product.StocksQuantity = stockManager.GetTheCount1OfProductByProductId(product, dic[productId].Depot);
                //    product.StocksQuantity = dic[productId].StockCheckQuantity;
                //    //修改產品
                //    productmanager.update(product);
                //}


                BL.V.CommitTransaction();
            }
            catch
            {
                BL.V.RollbackTransaction();
                throw;
            }
        }
예제 #23
0
 public void Insert(Model.StockEditor e)
 {
     this.Insert <Model.StockEditor>(e);
 }