Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            // first remove all blank row
            int count = 0;
            int length = deptSIDetailList.Count;
            for (int i = 0; i < length - count; i++)
            {
                StockInDetail detail = deptSIDetailList[i];
                if (string.IsNullOrEmpty(detail.Product.ProductMaster.ProductMasterId)
                    && string.IsNullOrEmpty(detail.Product.ProductMaster.ProductName))
                {
                    deptSIDetailList.RemoveAt(i - count);
                    count++;
                }
            }

            if (deptSIDetailList.Count == 0)
            {
                MessageBox.Show("Không có sản phẩm nào để nhập kho!!!!");
                return;
            }

            // validate quantity
            StringBuilder errMsg = new StringBuilder();
            int line = 1;
            foreach (StockInDetail detail in deptSIDetailList)
            {
                if (detail.Quantity == 0)
                {
                    errMsg.Append(" " + line + " ");
                }
                line++;
            }
            if (errMsg.Length > 0)
            {
                MessageBox.Show("Lỗi ở dòng " + errMsg.ToString() + " : Số lượng phải lớn hơn 0");
                return;
            }
            foreach (StockInDetail detail in deptSIDetailList)
            {
                count = 0;
                foreach (StockInDetail detail2 in deptSIDetailList)
                {
                    if (detail.DelFlg == CommonConstants.DEL_FLG_NO && detail.Product.ProductMaster.ProductMasterId.Equals(detail2.Product.ProductMaster.ProductMasterId))
                    {
                        if (count == 0)
                        {
                            count++;
                        }
                        else
                        {
                            MessageBox.Show("Lỗi : Mã hàng " + detail.Product.ProductMaster.ProductMasterId + " nhập 2 lần");
                            return;
                        }
                    }

                }
            }

            if (deptSI == null)
            {
                deptSI = new StockIn();
            }
            bool isNeedClearData = string.IsNullOrEmpty(deptSI.StockInId);
            deptSI.StockInDate = dtpImportDate.Value;
            deptSI.StockInDetails = deptSIDetailList;
            var eventArgs = new MainStockInEventArgs();
            eventArgs.StockIn = deptSI;
            EventUtility.fireEvent(SaveStockInEvent, this, eventArgs);
            if (!string.IsNullOrEmpty(deptSI.StockInId))
            {
                MessageBox.Show("Lưu thành công");
                if (isNeedClearData)
                {
                    deptSI = new StockIn();
                    deptSIDetailList.Clear();
                    CreateNewStockInDetail();
                }
            }
            else
            {
                MessageBox.Show("Có lỗi khi lưu");
            }
        }
Exemple #2
0
        private void DepartmentStockInExtra_Load(object sender, EventArgs e)
        {
            deptSIDetailList = new StockInDetailCollection(bdsStockIn);
            bdsStockIn.DataSource = deptSIDetailList;
            dgvDeptStockIn.DataError += new DataGridViewDataErrorEventHandler(dgvDeptStockIn_DataError);

            // create DepartmentStockIn
            if (deptSI == null)
            {
                deptSI = new StockIn();
                deptSI.CreateDate = DateTime.Now;
                deptSI.UpdateDate = DateTime.Now;
                deptSI.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                deptSI.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                deptSI.ExclusiveKey = 0;
                CreateNewStockInDetail();
                btnBarcode.Visible = false;
                numericUpDownBarcode.Visible = false;
                btnPreview.Visible = false;
            }
            else
            {
                btnBarcode.Visible = true;
                numericUpDownBarcode.Visible = true;
                btnPreview.Visible = true;
                IList deptStockInDetails = deptSI.StockInDetails;
                foreach (StockInDetail detail in deptStockInDetails)
                {
                    if (detail.DelFlg == CommonConstants.DEL_FLG_NO)
                    {
                        deptSIDetailList.Add(detail);
                        detail.OldQuantity = detail.Quantity;
                    }
                }

                for (int i = 0; i < dgvDeptStockIn.Columns.Count; i++)
                {
                    dgvDeptStockIn.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
                    if (i != QUANTITY_POS
                            && i != PRICE_POS
                            && i != SELL_PRICE_POS)
                    {
                        dgvDeptStockIn.Columns[i].ReadOnly = true;
                    }
                }
                txtDexcription.Text = deptSI.Description;
                txtStockInId.Text = deptSI.StockInId;
                CalculateTotalStorePrice();
            }
            deptSI.StockInDetails =
                    ObjectConverter.ConvertToNonGenericList<StockInDetail>(deptSIDetailList);
        }
Exemple #3
0
        /// <summary>
        /// Update StockIn to database.
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public void Update(StockIn data)
        {
            try
            {
                ISession session = HibernateTemplate.SessionFactory.GetCurrentSession();
                if (session != null)
                {
                    session.Update(data);
                    return;
                }
            }
            catch (Exception)
            {
            }

            HibernateTemplate.Update(data);
        }
Exemple #4
0
        private void btnAddProduct_Click(object sender, EventArgs e)
        {
            // create DepartmentStockIn
            if (deptSI == null)
            {
                deptSI = new StockIn();
            }
            deptSI.CreateDate = DateTime.Now;
            deptSI.UpdateDate = DateTime.Now;
            deptSI.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            deptSI.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            deptSI.ExclusiveKey = 0;
            int maxAddedItemsCount = int.Parse(numericUpDown.Text);
            for (int i = 0; i < maxAddedItemsCount; i++)
            {
                StockInDetail deptSIDet = CreateNewStockInDetail();

            }

            deptSI.StockInDetails =
                ObjectConverter.ConvertToNonGenericList<StockInDetail>(deptSIDetailList);
            bdsStockIn.EndEdit();

            for (int j = 0; j < maxAddedItemsCount; j++)
            {
                for (int i = 0; i <= SELL_PRICE_POS; i++)
                {
                    dgvDeptStockIn[i, deptSIDetailList.Count - j - 1].ReadOnly = false;
                }
            }
        }
        public void Update(StockIn data)
        {
            string dateStr = data.StockInDate.ToString("yyMMdd");

            var criteria = new ObjectCriteria();
            criteria.AddGreaterCriteria("ProductId", dateStr + "000000");

            var maxId = ProductDAO.SelectSpecificType(criteria, Projections.Max("ProductId"));
            var productId = (maxId == null)
                ? Int64.Parse(dateStr + "000001")
                : (Int64.Parse(maxId.ToString()) + 1);

            maxId = StockDAO.SelectSpecificType(null, Projections.Max("StockId"));
            var stockId = maxId == null ? 1 : Int64.Parse(maxId.ToString()) + 1;

            data.UpdateDate = DateTime.Now;
            data.UpdateId = ClientInfo.getInstance().LoggedUser.Name;

            int delFlg = 0;
            foreach (StockInDetail stockInDetail in data.StockInDetails)
            {
                // add product
                Product product = stockInDetail.Product;
                if (string.IsNullOrEmpty(product.ProductId))
                {
                    product.ProductId = string.Format("{0:000000000000}", productId++);
                    product.CreateDate = DateTime.Now;
                    product.UpdateDate = DateTime.Now;
                    product.Quantity = stockInDetail.Quantity;
                    product.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    product.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                    ProductDAO.Add(product);

                    // add dept stock in
                    var detailPK = new StockInDetailPK { ProductId = product.ProductId, StockInId = data.StockInId };
                    stockInDetail.StockInDetailPK = detailPK;
                    stockInDetail.CreateDate = DateTime.Now;
                    stockInDetail.UpdateDate = DateTime.Now;
                    stockInDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    stockInDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                    stockInDetail.ProductMaster = product.ProductMaster;
                    StockInDetailDAO.Add(stockInDetail);

                    // dept stock
                    var departmentStock = new Stock
                    {
                        StockId = stockId++,
                        CreateDate = DateTime.Now,
                        UpdateDate = DateTime.Now,
                        Product = product,
                        ProductMaster = product.ProductMaster,
                        Quantity = stockInDetail.Quantity,
                        GoodQuantity = stockInDetail.Quantity
                    };
                    departmentStock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    departmentStock.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                    StockDAO.Add(departmentStock);

                    var pricePk = new DepartmentPricePK { DepartmentId = 0, ProductMasterId = product.ProductMaster.ProductMasterId };

                    var price = DepartmentPriceDAO.FindById(pricePk);
                    if (price == null)
                    {
                        price = new DepartmentPrice { DepartmentPricePK = pricePk, Price = stockInDetail.SellPrice, UpdateDate = DateTime.Now, CreateDate = DateTime.Now };
                        price.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        price.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                        DepartmentPriceDAO.Add(price);
                    }
                }
                else
                {
                    var temProduct = ProductDAO.FindById(product.ProductId);
                    if (stockInDetail.DelFlg == 0)
                    {
                        temProduct.Quantity = product.Quantity;
                        temProduct.Price = product.Price;
                    }
                    else
                    {
                        temProduct.DelFlg = 1;
                        delFlg++;
                    }

                    temProduct.UpdateDate = DateTime.Now;
                    product.UpdateId = ClientInfo.getInstance().LoggedUser.Name;

                    ProductDAO.Update(temProduct);

                    // update dept stock in
                    var detailPK = new StockInDetailPK { ProductId = product.ProductId, StockInId = data.StockInId };
                    stockInDetail.StockInDetailPK = detailPK;
                    stockInDetail.UpdateDate = DateTime.Now;
                    stockInDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    StockInDetailDAO.Update(stockInDetail);

                    // update stock
                    criteria = new ObjectCriteria();
                    criteria.AddEqCriteria("Product.ProductId", product.ProductId);
                    criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                    IList departmentStockList = StockDAO.FindAll(criteria);
                    if (departmentStockList.Count > 0)
                    {
                        Stock stock = (Stock) departmentStockList[0];
                        stock.UpdateDate = DateTime.Now;
                        if (stockInDetail.DelFlg == 0)
                        {

                            stock.GoodQuantity = stock.GoodQuantity -
                                                       (stockInDetail.OldQuantity - stockInDetail.Quantity);
                            stock.Quantity = stock.ErrorQuantity + stock.GoodQuantity + stock.DamageQuantity +
                                     stock.UnconfirmQuantity + stock.LostQuantity;
                        }
                        else
                        {
                            stock.DelFlg = 1;
                        }
                        stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        stock.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                        StockDAO.Update(stock);

                    }

                    var pricePk = new DepartmentPricePK { DepartmentId = 0, ProductMasterId = product.ProductMaster.ProductMasterId };

                    var price = DepartmentPriceDAO.FindById(pricePk);
                    if (price == null)
                    {
                        price = new DepartmentPrice { DepartmentPricePK = pricePk, Price = stockInDetail.SellPrice, UpdateDate = DateTime.Now, CreateDate = DateTime.Now };
                        price.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        price.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                        DepartmentPriceDAO.Add(price);
                    }
                }
            }

            if (delFlg == data.StockInDetails.Count)
            {
                data.DelFlg = 1;
            }
            StockInDAO.Update(data);
        }
        void _departmentStockAdhocProcessingView_ProcessAdhocStocksEvent(object sender, DepartmentStockAdhocProcessingEventArgs e)
        {
            try
            {

                long departmentId = -1;
                StockOut stockOut = null;
                StockIn stockIn = new StockIn();
                stockIn.CreateDate = DateTime.Now;
                stockIn.UpdateDate = DateTime.Now;
                stockIn.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                stockIn.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                stockIn.StockInDate = DateTime.Now;
                stockIn.StockInType = 2; // stock in for fixing department stock quantity
                stockIn.StockInId = StockInLogic.FindMaxId();
                stockIn.StockInDetails = new ArrayList();
                long stockOutDetailMaxId = StockOutDetailLogic.FindMaxId() + 1;
                long stockOutMaxId = StockOutLogic.FindMaxId()+1;
                for (int i=0; i< e.DeptStockProcessedList.Count;i++)
                {
                    DepartmentStockTemp stockTemp = (DepartmentStockTemp) e.DeptStockProcessedList[i];
                    if(stockTemp.DepartmentStockTempPK.DepartmentId != departmentId)
                    {
                        departmentId = stockTemp.DepartmentStockTempPK.DepartmentId;

                        if (stockOut != null)
                        {
                            StockOutLogic.AddFixedStockOut(stockOut);
                        }
                        stockOut = new StockOut();
                        stockOut.CreateDate = DateTime.Now;
                        stockOut.UpdateDate = DateTime.Now;
                        stockOut.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                        stockOut.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        stockOut.StockOutDate = DateTime.Now;
                        stockOut.StockOutDetails = new ArrayList();
                        stockOut.DepartmentId = departmentId;
                        stockOut.DefectStatus = new StockDefectStatus{ DefectStatusId = 0};

                        stockOut.StockoutId =  stockOutMaxId++;
                    }

                    stockTemp.Fixed = 1;
                    stockTemp.UpdateDate = DateTime.Now;
                    stockTemp.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    DepartmentStockTempLogic.Update(stockTemp);
                    long realQty = stockTemp.GoodQuantity + stockTemp.ErrorQuantity + stockTemp.DamageQuantity +
                                   stockTemp.LostQuantity + stockTemp.UnconfirmQuantity;
                    if(stockTemp.Quantity < realQty)
                    {
                        long stockInQty = realQty - stockTemp.Quantity;
                        StockOutDetail stockOutDetail = new StockOutDetail();
                        stockOutDetail.CreateDate = DateTime.Now;
                        stockOutDetail.UpdateDate = DateTime.Now;
                        stockOutDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                        stockOutDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        stockOutDetail.Quantity = stockInQty;
                        stockOutDetail.Product = stockTemp.Product;
                        stockOutDetail.StockOutId = stockOut.StockoutId;
                        stockOutDetail.StockOut = stockOut;
                        stockOutDetail.DefectStatus = new StockDefectStatus{DefectStatusId = 0};
                        stockOutDetail.Description = "Export goods";
                        stockOutDetail.ProductMaster = stockTemp.ProductMaster;
                        stockOutDetail.StockOutDetailId = stockOutDetailMaxId++;
                        stockOut.StockOutDetails.Add(stockOutDetail);

                        StockInDetail stockInDetail = new StockInDetail();
                        stockInDetail.CreateDate = DateTime.Now;
                        stockInDetail.UpdateDate = DateTime.Now;
                        stockInDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                        stockInDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        stockInDetail.StockInType = 0;
                        stockInDetail.StockIn = stockIn;

                        stockInDetail.Quantity = stockInQty;
                        stockInDetail.Product = stockTemp.Product;
                        stockInDetail.ProductMaster = stockTemp.ProductMaster;
                        stockInDetail.StockInDetailPK = new StockInDetailPK
                                                            {
                                                                ProductId = stockTemp.Product.ProductId,
                                                                StockInId = stockIn.StockInId
                                                            };
                        stockIn.StockInDetails.Add(stockInDetail);

                    }

                    if (i == e.DeptStockProcessedList.Count - 1) // last item
                    {
                        StockOutLogic.AddFixedStockOut(stockOut);
                    }
                }
                StockInLogic.AddFixedStockIn(stockIn);

            }
            catch (Exception)
            {
                e.HasErrors = true;
                throw;
            }
        }
Exemple #7
0
 /// <summary>
 /// Add StockIn to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public StockIn Add(StockIn data)
 {
     HibernateTemplate.Save(data);
     return data;
 }
        public void AddReStock(StockIn data)
        {
            string dateStr = data.StockInDate.ToString("yyMMdd");
            var criteria = new ObjectCriteria();
            criteria.AddGreaterCriteria("StockInId", dateStr + "00000");
            var maxId = StockInDAO.SelectSpecificType(criteria, Projections.Max("StockInId"));
            var stockInId = maxId == null ? dateStr + "00001" : string.Format("{0:00000000000}", (Int64.Parse(maxId.ToString()) + 1));

            data.CreateDate = DateTime.Now;
            data.UpdateDate = DateTime.Now;
            data.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            data.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            data.StockInType = (long) 1;
            data.StockInId = stockInId;
            StockInDAO.Add(data);

            foreach (StockInDetail stockInDetail in data.StockInDetails)
            {
                // add dept stock in
                var detailPK = new StockInDetailPK { ProductId = stockInDetail.Product.ProductId, StockInId = stockInId };
                stockInDetail.StockInDetailPK = detailPK;
                stockInDetail.CreateDate = DateTime.Now;
                stockInDetail.UpdateDate = DateTime.Now;
                stockInDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                stockInDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                stockInDetail.ProductMaster = stockInDetail.Product.ProductMaster;
                //                    stockInDetail.CurrentStockQuantity = (sum == null) ? 0 : Int64.Parse(sum.ToString());
                StockInDetailDAO.Add(stockInDetail);
                ObjectCriteria stockCriteria = new ObjectCriteria();
                stockCriteria.AddEqCriteria("Product.ProductId", stockInDetail.Product.ProductId);
                IList stockList = StockDAO.FindAll(stockCriteria);

                // decrease error and increase good
                if(stockList != null)
                {
                    Stock stock = (Stock)stockList[0];
                    stock.ErrorQuantity -= stockInDetail.Quantity;
                    stock.GoodQuantity += stockInDetail.Quantity;
                    stock.Quantity = stock.ErrorQuantity + stock.GoodQuantity + stock.DamageQuantity +
                                     stock.UnconfirmQuantity + stock.LostQuantity;
                    StockDAO.Update(stock);
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show(
                "Bạn hãy kiểm tra kỹ trước khi lưu số liệu bởi vì sau khi lưu sẽ không thay đổi được nữa. Bạn có chắc chắn muốn lưu ?", "Xác nhận",
                MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (result == System.Windows.Forms.DialogResult.No)
            {
                return;
            }
            // first remove all blank row
            int count = 0;
            int length = deptSIDetailList.Count;
            for (int i = 0; i < length - count; i++)
            {
                StockInDetail detail = deptSIDetailList[i];
                if (string.IsNullOrEmpty(detail.Product.ProductMaster.ProductMasterId)
                    && string.IsNullOrEmpty(detail.Product.ProductMaster.ProductName))
                {
                    deptSIDetailList.RemoveAt(i - count);
                    count++;
                }
            }

            if (deptSIDetailList.Count == 0)
            {
                MessageBox.Show("Không có sản phẩm nào để nhập kho!!!!");
                return;
            }

            // validate quantity
            StringBuilder errMsg = new StringBuilder();
            int line = 1;
            foreach (StockInDetail detail in deptSIDetailList)
            {
                if (detail.Quantity == 0)
                {
                    errMsg.Append(" " + line + " ");
                }
                line++;
            }
            if (errMsg.Length > 0)
            {
                MessageBox.Show("Lỗi ở dòng " + errMsg.ToString() + " : Số lượng phải lớn hơn 0");
                return;
            }
            foreach (StockInDetail detail in deptSIDetailList)
            {
                count = 0;
                foreach (StockInDetail detail2 in deptSIDetailList)
                {
                    if (detail.DelFlg == CommonConstants.DEL_FLG_NO && detail.Product.ProductMaster.ProductMasterId.Equals(detail2.Product.ProductMaster.ProductMasterId))
                    {
                        if (count == 0)
                        {
                            count++;
                        }
                        else
                        {
                            MessageBox.Show("Lỗi : Mã hàng " + detail.Product.ProductMaster.ProductMasterId + " nhập 2 lần");
                            return;
                        }
                    }

                }
            }

            bool isNeedClearData = string.IsNullOrEmpty(deptSI.StockInId);
            deptSI.StockInDate = dtpImportDate.Value;
            deptSI.StockInDetails = deptSIDetailList;
            deptSI.Description = txtDexcription.Text;
            var eventArgs = new MainStockInEventArgs();
            eventArgs.StockIn = StockIn;
            eventArgs.StockIn.StockInDetails = ObjectConverter.ConvertToNonGenericList(deptSIDetailList);
            EventUtility.fireEvent(SaveStockInEvent, this, eventArgs);
            if (eventArgs.EventResult != null)
            {
                MessageBox.Show("Lưu thành công");
                if (isNeedClearData)
                {
                    deptSI = new StockIn();
                    deptSIDetailList.Clear();
                    txtDexcription.Text = "";
                    txtPriceIn.Text = "";
                    txtPriceOut.Text = "";
                    txtSumProduct.Text = "";
                    txtSumValue.Text = "";
                    ClearSelectionOnListBox(lstColor);
                    ClearSelectionOnListBox(lstSize);
                    //CreateNewStockInDetail();
                }
            }
            else
            {
                //MessageBox.Show("Có lỗi khi lưu");
            }
        }
Exemple #10
0
 /// <summary>
 /// Update StockIn to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Update(StockIn data)
 {
     HibernateTemplate.Update(data);
 }
Exemple #11
0
 public void UpdateMaster(StockIn data)
 {
     StockInDAO.Update(data);
 }
Exemple #12
0
        public StockIn Add(StockIn data)
        {
            string dateStr = data.StockInDate.ToString("yyMMdd");
            var criteria = new ObjectCriteria();
            criteria.AddGreaterCriteria("StockInId", dateStr + "00000");
            var maxId = StockInDAO.SelectSpecificType(criteria, Projections.Max("StockInId"));
            var stockInId = maxId == null ? dateStr + "00001" : string.Format("{0:00000000000}", (Int64.Parse(maxId.ToString()) + 1));

            data.StockInId = stockInId;
            /*criteria = new ObjectCriteria();
            criteria.AddGreaterCriteria("ProductId", dateStr + "000000");

            maxId = ProductDAO.SelectSpecificType(criteria, Projections.Max("ProductId"));
            var productId = (maxId == null)
                ? Int64.Parse(dateStr + "000001")
                : (Int64.Parse(maxId.ToString()) + 1);*/

            maxId = StockDAO.SelectSpecificType(null, Projections.Max("StockId"));
            var stockId = maxId == null ? 1 : Int64.Parse(maxId.ToString()) + 1;

            data.CreateDate = DateTime.Now;
            data.UpdateDate = DateTime.Now;
            data.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            data.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            StockInDAO.Add(data);
            IDictionary<string, string> maxPrdIdList = new Dictionary<string, string>();
            foreach (StockInDetail stockInDetail in data.StockInDetails)
            {
                // add product
                Product product = stockInDetail.Product;
                if (string.IsNullOrEmpty(product.ProductId))
                {
                    // find master ID
                    string masterId = product.ProductMaster.ProductMasterId;
                    masterId = masterId.Substring(6);
                    // search in product table to get latest number
                    string nextPrdId = GetProductIdFromList(maxPrdIdList,masterId);
                    if (nextPrdId == null)
                    {
                        string shortDate = StringUtility.ConvertDateToFourChar(DateTime.Now);
                        ObjectCriteria prdCrit = new ObjectCriteria();
                        prdCrit.AddLikeCriteria("ProductId", masterId + shortDate + "%");
                        var maxIPrdId = ProductDAO.SelectSpecificType(prdCrit, Projections.Max("ProductId"));
                        string productId = (maxIPrdId == null)
                                            ? masterId + shortDate + "01"
                                            : IncreaseMaxProductId(maxIPrdId.ToString());

                        nextPrdId = productId;
                        maxPrdIdList[masterId] = nextPrdId;
                    }
                    product.ProductId = nextPrdId;
                    // increase product id and grant to the dictionary
                    nextPrdId = IncreaseMaxProductId(nextPrdId);
                    maxPrdIdList[masterId] = nextPrdId;
                    product.CreateDate = DateTime.Now;
                    product.UpdateDate = DateTime.Now;
                    product.Quantity = stockInDetail.Quantity;
                    product.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    product.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                    ProductDAO.Add(product);

                    criteria = new ObjectCriteria();
                    criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                    criteria.AddEqCriteria("ProductMaster.ProductMasterId", product.ProductMaster.ProductMasterId);
            //                    var sum = StockDAO.SelectSpecificType(criteria, Projections.Sum("Quantity"));

                    // add dept stock in
                    var detailPK = new StockInDetailPK { ProductId = product.ProductId, StockInId = stockInId};
                    stockInDetail.StockInDetailPK = detailPK;
                    stockInDetail.CreateDate = DateTime.Now;
                    stockInDetail.UpdateDate = DateTime.Now;
                    stockInDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    stockInDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                    stockInDetail.ProductMaster = product.ProductMaster;
            //                    stockInDetail.CurrentStockQuantity = (sum == null) ? 0 : Int64.Parse(sum.ToString());
                    StockInDetailDAO.Add(stockInDetail);

                    // if do not needs to confirm then update stock.
                    if (data.ConfirmFlg != 1)
                    {
                        // add stock
                        var stock = new Stock
                                        {
                                            StockId = stockId++,
                                            CreateDate = DateTime.Now,
                                            UpdateDate = DateTime.Now,
                                            Product = product,
                                            Quantity = stockInDetail.Quantity,
                                            GoodQuantity = stockInDetail.Quantity,
                                            ProductMaster = product.ProductMaster
                                        };
                        stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        stock.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                        StockDAO.Add(stock);
                    }

                    var pricePk = new DepartmentPricePK { DepartmentId = 0, ProductMasterId = product.ProductMaster.ProductMasterId };

                    var price = DepartmentPriceDAO.FindById(pricePk);
                    if (price == null)
                    {
                        price = new DepartmentPrice
                                    {
                                        DepartmentPricePK = pricePk,
                                        Price = stockInDetail.SellPrice,
                                        WholeSalePrice = stockInDetail.WholeSalePrice,
                                        UpdateDate = DateTime.Now,
                                        CreateDate = DateTime.Now
                                    };
                        if(stockInDetail.DepartmentPrice!=null)
                        {
                            price.WholeSalePrice = stockInDetail.DepartmentPrice.WholeSalePrice;
                        }
                        price.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        price.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                        DepartmentPriceDAO.Add(price);
                    }
                    else
                    {
                        // don't need to update price
                        //price.Price = stockInDetail.SellPrice;

                        price.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        price.UpdateDate = DateTime.Now;
                        //DepartmentPriceDAO.Update(price);
                    }
                }
            }

            return data;
        }
Exemple #13
0
        public void UpdateDetail(StockIn data)
        {
            string dateStr = data.StockInDate.ToString("yyMMdd");

            var criteria = new ObjectCriteria();
            criteria.AddGreaterCriteria("ProductId", dateStr + "000000");

            //var maxId = ProductDAO.SelectSpecificType(criteria, Projections.Max("ProductId"));
            /*var productId = (maxId == null)
                ? Int64.Parse(dateStr + "000001")
                : (Int64.Parse(maxId.ToString()) + 1);*/

            var maxId = StockDAO.SelectSpecificType(null, Projections.Max("StockId"));
            var stockId = maxId == null ? 1 : Int64.Parse(maxId.ToString()) + 1;

            data.UpdateDate = DateTime.Now;
            data.UpdateId = ClientInfo.getInstance().LoggedUser.Name;

            int delFlg = 0;
            IDictionary<string, string> maxPrdIdList = new Dictionary<string, string>();
            foreach (StockInDetail stockInDetail in data.StockInDetails)
            {
                // add product
                Product product = stockInDetail.Product;
                if (string.IsNullOrEmpty(product.ProductId))
                {
                    //product.ProductId = string.Format("{0:000000000000}", productId++);
                    // find master ID
                    string masterId = product.ProductMaster.ProductMasterId;
                    masterId = masterId.Substring(6);
                    // search in product table to get latest number
                    string nextPrdId = GetProductIdFromList(maxPrdIdList, masterId);
                    if (nextPrdId == null)
                    {
                        string shortDate = StringUtility.ConvertDateToFourChar(DateTime.Now);
                        ObjectCriteria prdCrit = new ObjectCriteria();
                        prdCrit.AddLikeCriteria("ProductId", masterId + shortDate + "%");
                        var maxIPrdId = ProductDAO.SelectSpecificType(prdCrit, Projections.Max("ProductId"));
                        string productId = (maxIPrdId == null)
                                            ? masterId + shortDate + "01"
                                            : IncreaseMaxProductId(maxIPrdId.ToString());

                        nextPrdId = productId;
                        maxPrdIdList[masterId] = nextPrdId;
                    }
                    product.ProductId = nextPrdId;
                    // increase product id and grant to the dictionary
                    nextPrdId = IncreaseMaxProductId(nextPrdId);
                    maxPrdIdList[masterId] = nextPrdId;

                    product.CreateDate = DateTime.Now;
                    product.UpdateDate = DateTime.Now;
                    product.Quantity = stockInDetail.Quantity;
                    product.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    product.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                    ProductDAO.Add(product);

                    // add dept stock in
                    var detailPK = new StockInDetailPK { ProductId = product.ProductId, StockInId = data.StockInId };
                    stockInDetail.StockInDetailPK = detailPK;
                    stockInDetail.CreateDate = DateTime.Now;
                    stockInDetail.UpdateDate = DateTime.Now;
                    stockInDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    stockInDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                    stockInDetail.ProductMaster = product.ProductMaster;
                    StockInDetailDAO.Add(stockInDetail);

                    if (!ClientSetting.ImportConfirmation)
                    {
                        // dept stock
                        var stock = new Stock
                        {
                            StockId = stockId++,
                            CreateDate = DateTime.Now,
                            UpdateDate = DateTime.Now,
                            Product = product,
                            ProductMaster = product.ProductMaster,
                            Quantity = stockInDetail.Quantity,
                            GoodQuantity = stockInDetail.Quantity
                        };
                        stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        stock.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                        StockDAO.Add(stock);
                    }
                    var pricePk = new DepartmentPricePK { DepartmentId = 0, ProductMasterId = product.ProductMaster.ProductMasterId };

                    var price = DepartmentPriceDAO.FindById(pricePk);
                    if (price == null)
                    {
                        price = new DepartmentPrice { DepartmentPricePK = pricePk, Price = stockInDetail.SellPrice, UpdateDate = DateTime.Now, CreateDate = DateTime.Now };
                        price.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        price.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                        DepartmentPriceDAO.Add(price);
                    }
                }
                else
                {
                    var temProduct = ProductDAO.FindById(product.ProductId);
                    if (stockInDetail.DelFlg == 0)
                    {
                        temProduct.Quantity = product.Quantity;
                        temProduct.Price = product.Price;
                    }
                    else
                    {
                        temProduct.DelFlg = 1;
                        delFlg++;
                    }

                    temProduct.UpdateDate = DateTime.Now;
                    product.UpdateId = ClientInfo.getInstance().LoggedUser.Name;

                    ProductDAO.Update(temProduct);

                    // update dept stock in
                    var detailPK = new StockInDetailPK { ProductId = product.ProductId, StockInId = data.StockInId };
                    stockInDetail.StockInDetailPK = detailPK;
                    stockInDetail.UpdateDate = DateTime.Now;
                    stockInDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    StockInDetailDAO.Update(stockInDetail);

                    // if do not need to confirm then update stock
                    if (data.ConfirmFlg != 1)
                    {
                        // update stock
                        criteria = new ObjectCriteria();
                        criteria.AddEqCriteria("Product.ProductId", product.ProductId);
                        criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                        IList stockList = StockDAO.FindAll(criteria);
                        if (stockList.Count > 0)
                        {
                            Stock stock = (Stock)stockList[0];
                            stock.UpdateDate = DateTime.Now;
                            if (stockInDetail.DelFlg == 0)
                            {

                                stock.GoodQuantity = stock.GoodQuantity -
                                                     (stockInDetail.OldQuantity - stockInDetail.Quantity);
                                stock.Quantity = stock.ErrorQuantity + stock.GoodQuantity + stock.DamageQuantity +
                                                 stock.UnconfirmQuantity + stock.LostQuantity;
                            }
                            else
                            {
                                stock.DelFlg = 1;
                            }
                            stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                            stock.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                            StockDAO.Update(stock);

                        }
                        else
                        {
                            // in case confirmation so stock in has been confirmed to update
                            if (ClientSetting.ImportConfirmation)
                            {
                                // dept stock
                                var stock = new Stock
                                {
                                    StockId = stockId++,
                                    CreateDate = DateTime.Now,
                                    UpdateDate = DateTime.Now,
                                    Product = product,
                                    ProductMaster = product.ProductMaster,
                                    Quantity = stockInDetail.Quantity,
                                    GoodQuantity = stockInDetail.Quantity
                                };
                                stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                                stock.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                                StockDAO.Add(stock);
                            }
                        }
                    }

                    var pricePk = new DepartmentPricePK { DepartmentId = 0, ProductMasterId = product.ProductMaster.ProductMasterId };

                    var price = DepartmentPriceDAO.FindById(pricePk);
                    if (price == null)
                    {
                        price = new DepartmentPrice { DepartmentPricePK = pricePk, Price = stockInDetail.SellPrice, UpdateDate = DateTime.Now, CreateDate = DateTime.Now };
                        price.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        price.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                        DepartmentPriceDAO.Add(price);
                    }
                }
            }

            if (delFlg == data.StockInDetails.Count)
            {
                data.DelFlg = 1;
            }
        }
Exemple #14
0
        public void AddFixedStockIn(StockIn stockIn)
        {
            StockInDAO.Add(stockIn);

            foreach (StockInDetail inDetail in stockIn.StockInDetails)
            {
                StockInDetailDAO.Add(inDetail);
            }
        }
Exemple #15
0
 /// <summary>
 /// Delete StockIn from database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Delete(StockIn data)
 {
     HibernateTemplate.Delete(data);
 }
Exemple #16
0
        public void AddForStockOutToProducer(StockIn stockIn)
        {
            string dateStr = stockIn.StockInDate.ToString("yyMMdd");
            var criteria = new ObjectCriteria();
            var maxId = StockInDAO.SelectSpecificType(criteria, Projections.Max("StockInId"));
            var stockInId = maxId == null ? dateStr + "00001" : string.Format("{0:00000000000}", (Int64.Parse(maxId.ToString()) + 1));
            stockIn.StockInId = stockInId;
            StockInDAO.Add(stockIn);

            foreach (StockInDetail stockInDetail in stockIn.StockInDetails)
            {
                // add dept stock in
                var detailPK = new StockInDetailPK { ProductId = stockInDetail.Product.ProductId, StockInId = stockInId };
                stockInDetail.StockInDetailPK = detailPK;
                StockInDetailDAO.Add(stockInDetail);

                ObjectCriteria stockCriteria = new ObjectCriteria();
                stockCriteria.AddEqCriteria("Product.ProductId", stockInDetail.Product.ProductId);
                IList stockList = StockDAO.FindAll(stockCriteria);
                // increase good
                if (stockList != null)
                {
                    Stock stock = (Stock)stockList[0];
                    stock.GoodQuantity += stockInDetail.Quantity;
                    stock.Quantity = stock.ErrorQuantity + stock.GoodQuantity + stock.DamageQuantity +
                                     stock.UnconfirmQuantity + stock.LostQuantity;
                    StockDAO.Update(stock);
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            long cost = 0;
            if (!NumberUtility.CheckLongNullIsZero(txtCost.Text, out cost) || cost < 0)
            {
                MessageBox.Show("Chi phí phải là số dương");
                return;
            }
            if (deptSIDetailList.Count == 0)
            {
                MessageBox.Show("Không có sản phẩm nào để nhập kho!!!!");
                return;
            }

            // validate quantity
            StringBuilder errMsg = new StringBuilder();
            int line = 1;
            foreach (StockInDetail detail in deptSIDetailList)
            {
                if (detail.Quantity <= 0)
                {
                    MessageBox.Show("Lỗi ở dòng " + line + " : Số lượng phải lớn hơn 0");
                    return;
                }

                if (detail.Quantity > (detail.StockOutQuantity-detail.ReStockQuantity))
                {
                    MessageBox.Show("Lỗi ở dòng " + errMsg.ToString() + " : Số lượng phải nhỏ hơn số lượng tạm xuất là " + (detail.StockOutQuantity - detail.ReStockQuantity).ToString());
                    return;
                }
                line++;
            }

            if (deptSI == null)
            {
                deptSI = new StockIn();
            }
            bool isNeedClearData = string.IsNullOrEmpty(deptSI.StockInId);
            deptSI.StockInDate = dtpImportDate.Value;
            deptSI.StockInDetails = deptSIDetailList;
            deptSI.Description = txtDexcription.Text;
            deptSI.StockInCost = cost;
            var eventArgs = new MainStockInEventArgs();
            eventArgs.StockIn = deptSI;
            EventUtility.fireEvent(SaveReStockInEvent, this, eventArgs);
            if (eventArgs.EventResult != null)
            {
                MessageBox.Show("Lưu thành công");
                if (isNeedClearData)
                {
                    deptSI = new StockIn();
                    deptSIDetailList.Clear();
                    txtBarcode.Text = "";
                    txtQty.Text = "";
                    txtDexcription.Text = "";
                    txtPriceIn.Text = "";
                    txtPriceOut.Text = "";
                    txtSumProduct.Text = "";
                    txtSumValue.Text = "";
                    ClearSelectionOnListBox(lstColor);
                    ClearSelectionOnListBox(lstSize);
                    //CreateNewStockInDetail();
                }
            }
            else
            {
                //MessageBox.Show("Có lỗi khi lưu");
            }
        }
Exemple #18
0
 public void Delete(StockIn data)
 {
     StockInDAO.Delete(data);
 }
        public BlockInDetail Add(BlockInDetail data)
        {
            var pk = new BlockInDetailPK {BlockId = 1};
            var maxId = BlockInDetailDAO.SelectSpecificType(null, Projections.Max("BlockInDetailPK.BlockDetailId"));

            pk.BlockDetailId = maxId == null ? "1" : (Int64.Parse(maxId.ToString()) + 1).ToString();

            data.BlockInDetailPK = pk;

            var maxProduct = ProductDAO.SelectSpecificType(null, Projections.Max("ProductId"));
            Int64 maxProductId = 1;
            if (maxProduct != null)
            {
                maxProductId = (Int64)maxProduct + 1;
            }

            var maxStockInId = StockInDAO.SelectSpecificType(null, Projections.Max("StockInId"));
            if (maxStockInId == null)
            {
                maxStockInId = (long) 1;
            }
            else
            {
                maxStockInId = (long)maxStockInId + 1;
            }

            var stockIn = new StockIn {StockInDate = data.ImportDate};
            data.StockInId = (long)maxStockInId;

            BlockInDetailDAO.Add(data);
            StockInDAO.Add(stockIn);

            foreach (Product product in data.Products)
            {
                // TODO product.ProductId = maxProductId++;
                product.BlockInDetail = data;
                ProductDAO.Add(product);

                var stockInDetail = new StockInDetail
                                        {
                                            Product = product,
                                            ProductId = product.ProductId,
                                            StockIn = stockIn,
                                            Quantity = product.Quantity,
                                            Price = product.Price,
                                            StockInType = (Int64)StockInDetail.StockInStatus.IMPORTED,
                                            StockInDetailPK =
                                                new StockInDetailPK
                                                    {StockInId = stockIn.StockInId, ProductId = product.ProductId}
                                        };
                StockInDetailDAO.Add(stockInDetail);
            }

            return data;
        }
Exemple #20
0
        public StockIn Add(StockIn data)
        {
            string dateStr = data.StockInDate.ToString("yyMMdd");
            var criteria = new ObjectCriteria();
            criteria.AddGreaterCriteria("StockInId", dateStr + "00000");
            var maxId = StockInDAO.SelectSpecificType(criteria, Projections.Max("StockInId"));
            var stockInId = maxId == null ? dateStr + "00001" : string.Format("{0:00000000000}", (Int64.Parse(maxId.ToString()) + 1));

            data.StockInId = stockInId;
            criteria = new ObjectCriteria();
            criteria.AddGreaterCriteria("ProductId", dateStr + "000000");

            maxId = ProductDAO.SelectSpecificType(criteria, Projections.Max("ProductId"));
            var productId = (maxId == null)
                ? Int64.Parse(dateStr + "000001")
                : (Int64.Parse(maxId.ToString()) + 1);

            maxId = StockDAO.SelectSpecificType(null, Projections.Max("StockId"));
            var stockId = maxId == null ? 1 : Int64.Parse(maxId.ToString()) + 1;

            data.CreateDate = DateTime.Now;
            data.UpdateDate = DateTime.Now;
            data.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            data.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            StockInDAO.Add(data);

            foreach (StockInDetail stockInDetail in data.StockInDetails)
            {
                // add product
                Product product = stockInDetail.Product;
                if (string.IsNullOrEmpty(product.ProductId))
                {
                    product.ProductId = string.Format("{0:000000000000}", productId++);
                    product.CreateDate = DateTime.Now;
                    product.UpdateDate = DateTime.Now;
                    product.Quantity = stockInDetail.Quantity;
                    product.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    product.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                    ProductDAO.Add(product);

                    criteria = new ObjectCriteria();
                    criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                    criteria.AddEqCriteria("ProductMaster.ProductMasterId", product.ProductMaster.ProductMasterId);
            //                    var sum = StockDAO.SelectSpecificType(criteria, Projections.Sum("Quantity"));

                    // add dept stock in
                    var detailPK = new StockInDetailPK { ProductId = product.ProductId, StockInId = stockInId};
                    stockInDetail.StockInDetailPK = detailPK;
                    stockInDetail.CreateDate = DateTime.Now;
                    stockInDetail.UpdateDate = DateTime.Now;
                    stockInDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    stockInDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                    stockInDetail.ProductMaster = product.ProductMaster;
            //                    stockInDetail.CurrentStockQuantity = (sum == null) ? 0 : Int64.Parse(sum.ToString());
                    StockInDetailDAO.Add(stockInDetail);

                    // dept stock
                    var stock = new Stock
                    {
                        StockId = stockId++,
                        CreateDate = DateTime.Now,
                        UpdateDate = DateTime.Now,
                        Product = product,
                        Quantity = stockInDetail.Quantity,
                        GoodQuantity = stockInDetail.Quantity,
                        ProductMaster = product.ProductMaster
                    };
                    stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    stock.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                    StockDAO.Add(stock);

                    var pricePk = new DepartmentPricePK { DepartmentId = 0, ProductMasterId = product.ProductMaster.ProductMasterId };

                    var price = DepartmentPriceDAO.FindById(pricePk);
                    if (price == null)
                    {
                        price = new DepartmentPrice { DepartmentPricePK = pricePk, Price = stockInDetail.SellPrice, UpdateDate = DateTime.Now, CreateDate = DateTime.Now };
                        price.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        price.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                        DepartmentPriceDAO.Add(price);
                    }
                    else
                    {
                        price.Price = stockInDetail.SellPrice;
                        price.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        price.UpdateDate = DateTime.Now;
                        DepartmentPriceDAO.Update(price);
                    }
                }
            }

            return data;
        }
 private void button3_Click(object sender, EventArgs e)
 {
     deptSI = new StockIn();
     deptSIDetailList.Clear();
     txtDexcription.Text = "";
     txtPriceIn.Text = "";
     txtPriceOut.Text = "";
     txtSumProduct.Text = "";
     txtSumValue.Text = "";
     ClearSelectionOnListBox(lstColor);
     ClearSelectionOnListBox(lstSize);
     cboProductMasters.Text = "";
 }
 private static object[] AddProductToDataGrid(StockIn stockInDetail)
 {
     var obj = new object[MAX_COLUMNS];
     obj[STOCK_IN_ID_POS] = stockInDetail.StockInId;
     obj[STOCK_IN_DATE_POS] = stockInDetail.StockInDate.ToString("dd/MM/yyyy HH:mm:ss");
     long quantity = 0;
     foreach (StockInDetail detail in stockInDetail.StockInDetails)
     {
         if (detail.DelFlg == 0)
         {
             quantity += detail.Quantity;
         }
     }
     obj[PRODUCT_QUANTITY_POS] = quantity;
     obj[UPDATER_POS] = stockInDetail.UpdateId;
     return obj;
 }
        void inventoryCheckingView_SaveInventoryCheckingEvent(object sender, InventoryCheckingEventArgs e)
        {
            if(e.SaveStockList!=null && e.SaveStockList.Count > 0)
               {
               /*foreach (Stock stock in e.SaveStockList)
               {
                   stock.CreateDate = DateTime.Now;
                   stock.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                   stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                   stock.UpdateDate = DateTime.Now;
                   stock.DelFlg = 0;

                   // calculate business
                   StockLogic.Update(stock);

                   e.HasErrors = false;

               }*/
               // ++ AMEND FOR SHOES STOCK CHECKING 19/10/2009
               StockIn stockIn = new StockIn();
               stockIn.NotUpdateMainStock = false;
               stockIn.CreateDate = DateTime.Now;
               stockIn.UpdateDate = DateTime.Now;
               stockIn.StockInDate = DateTime.Now;
               stockIn.CreateId = ClientInfo.getInstance().LoggedUser.Name;
               stockIn.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
               stockIn.DelFlg = 0;
               stockIn.Description = " NHẬP TỪ SỐ LƯỢNG KIỂM KÊ";

               IList stockInDetailList = new ArrayList();
               foreach (Stock stock in e.SaveStockList)
               {
                   StockInDetail inDetail = new StockInDetail();
                   inDetail.CreateDate = DateTime.Now;
                   inDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                   inDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                   inDetail.UpdateDate = DateTime.Now;
                   inDetail.DelFlg = 0;
                   inDetail.Product = stock.Product;
                   inDetail.Quantity = stock.GoodQuantity;
                   inDetail.DelFlg = 0;
                   inDetail.StockIn = stockIn;
                   // calculate business
                   inDetail.StockInDetailPK = new StockInDetailPK
                                                  {
                                                      ProductId = stock.Product.ProductId
                                                  };
                   stockInDetailList.Add(inDetail);
               }
               stockIn.StockInDetails = stockInDetailList;
               StockInLogic.AddForStockOutToProducer(stockIn);
               e.HasErrors = false;
               // ++ AMEND FOR SHOES STOCK CHECKING 19/10/2009
               }
        }