コード例 #1
0
        private void btnBillChoosing_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection selectedRows = dgvSaleList.SelectedRows;
            GoodsSaleListEventArgs eventArgs = new GoodsSaleListEventArgs();
            PurchaseOrderView view = bdsPurchaseOrders[dgvSaleList.CurrentCell.OwningRow.Index] as PurchaseOrderView;
            if(view == null || view.PurchaseOrder == null)
            {
                MessageBox.Show("Bạn nên chọn hóa đơn bán hàng, không nên chọn hóa đơn trả hàng");
                return;
            }

            eventArgs.SelectedOrder = view.PurchaseOrder;
            EventUtility.fireEvent(SelectGoodsSaleEvent,this,eventArgs);
            Close();
        }
コード例 #2
0
 void form_SelectGoodsSaleEvent(object sender, GoodsSaleListEventArgs e)
 {
     txtBillNumber.Text = e.SelectedOrder.PurchaseOrderPK.PurchaseOrderId;
 }
コード例 #3
0
 void goodsSaleListController_CompletedGoodsSaleListSearchEvent(object sender, GoodsSaleListEventArgs e)
 {
     //e.PurchaseOrders.ParentBindingSource = bdsPurchaseOrders;
     bdsPurchaseOrders.DataSource = e.PurchaseOrderViewList;
     bdsPurchaseOrders.EndEdit();
     bdsPurchaseOrders.ResetBindings(false);
     long totalAmount = 0;
     long sellQty = 0;
     long retQty = 0;
     foreach (PurchaseOrderView view in e.PurchaseOrderViewList)
     {
         totalAmount += (view.SellAmount - view.ReturnAmount);
         sellQty += view.SellQuantity;
         retQty += view.ReturnQuantity;
     }
     txtTotalAmount.Text = totalAmount.ToString("##,#00");
     txtSellQty.Text = sellQty.ToString();
     txtRetQty.Text = retQty.ToString();
 }
コード例 #4
0
        private void FillForm()
        {
            Department department = CurrentDepartment.Get();
            txtDepartmentId.Text = department.DepartmentId.ToString().PadLeft(3, '0');
            txtDepartmentName.Text = department.DepartmentName;

            int currentYear = DateTime.Now.Year;
            int currentMonth = DateTime.Now.Month;
            int daysOfMonth = DateTime.DaysInMonth(currentYear, currentMonth);
            // get first day of month
            txtDateFrom.Text = new DateTime(currentYear,currentMonth,1).ToString("dd/MM/yyyy");
            // get last day of month
            txtDateTo.Text = new DateTime(currentYear, currentMonth, daysOfMonth).ToString("dd/MM/yyyy");

            GoodsSaleListEventArgs goodsSaleListEventArgs = new GoodsSaleListEventArgs();
            goodsSaleListEventArgs.PurchaseOrderSearchCriteria = CreateCriteria();
            DateTime firstOfMonth = DateTime.ParseExact(txtDateFrom.Text, "dd/MM/yyyy", null);
            DateTime lastOfMonth = DateTime.ParseExact(txtDateTo.Text, "dd/MM/yyyy", null);
            goodsSaleListEventArgs.FromDate = DateUtility.ZeroTime(firstOfMonth);
            goodsSaleListEventArgs.ToDate = DateUtility.MaxTime(lastOfMonth);

            EventUtility.fireEvent(GoodsSaleListSearchEvent, this, goodsSaleListEventArgs);
        }
コード例 #5
0
        private void SearchGoodsAndReturnsInRange(object sender, GoodsSaleListEventArgs args)
        {
            IList list = PurchaseOrderLogic.FindAll(args.PurchaseOrderSearchCriteria);
            IList collection = new ArrayList();
            foreach (PurchaseOrder order in list)
            {
                PurchaseOrderView view = new PurchaseOrderView();
                view.PurchaseOrder = order;
                view.PurchaseOrderId = order.PurchaseOrderPK.PurchaseOrderId;

                long SellAmount = 0;
                long SellQuantity = 0;
                string SellDescription = "";
                long RetAmount = 0;
                long RetQuantity = 0;
                string RetDescription = "";
                foreach (PurchaseOrderDetail detail in order.PurchaseOrderDetails)
                {
                    SellDescription += detail.Product.ProductMaster.ProductName + " ";
                    SellAmount += detail.Quantity*detail.Price;
                    SellQuantity += detail.Quantity;
                }

                ObjectCriteria criteria = new ObjectCriteria();
                criteria.AddEqCriteria("NextPurchaseOrderId", order.PurchaseOrderPK.PurchaseOrderId);
                criteria.AddEqCriteria("ReturnPoPK.DepartmentId", order.PurchaseOrderPK.DepartmentId);
                IList returnPOList = ReturnPoLogic.FindAll(criteria);
                foreach (ReturnPo returnPo in returnPOList)
                {
                    RetDescription += returnPo.Product.ProductMaster.ProductName + " ";
                    long retPrice = returnPo.Price;
                    if (retPrice == 0)
                    {
                        DepartmentPricePK deptPricePK = new DepartmentPricePK();
                        deptPricePK.DepartmentId = 0;
                        deptPricePK.ProductMasterId = returnPo.Product.ProductMaster.ProductMasterId;
                        DepartmentPrice price = DepartmentPriceLogic.FindById(deptPricePK);
                        if (price != null)
                        {
                            retPrice = price.Price;
                        }
                    }
                    RetAmount += returnPo.Quantity * retPrice;
                    RetQuantity += returnPo.Quantity;
                }

                view.ReturnPOList = returnPOList;
                view.SellDescription = SellDescription;
                view.SellAmount = SellAmount;
                view.SellQuantity = SellQuantity;
                view.ReturnAmount = RetAmount;
                view.ReturnDescription = RetDescription;
                view.ReturnQuantity = RetQuantity;
                view.IssueDate = order.CreateDate;
                collection.Add(view);
            }

            ObjectCriteria NAcriteria = new ObjectCriteria();
            NAcriteria.AddEqCriteria("ReturnPoPK.DepartmentId", CurrentDepartment.Get().DepartmentId);
            NAcriteria.AddGreaterOrEqualsCriteria("ReturnPoPK.CreateDate", args.FromDate)
                .AddLesserOrEqualsCriteria("ReturnPoPK.CreateDate", args.ToDate);
            IList allReturnPOList = ReturnPoLogic.FindAll(NAcriteria);

            IList legalReturnPOList = new ArrayList();
            if(allReturnPOList!= null)
            {
                foreach (ReturnPo returnPo in allReturnPOList)
                {
                    if(string.IsNullOrEmpty(returnPo.NextPurchaseOrderId))
                            legalReturnPOList.Add(returnPo);

                }
            }

            string retNAPOId = "";
            PurchaseOrderView retNAView = new PurchaseOrderView();
            retNAView.ReturnPOList = new ArrayList();
            IList retNAList = new ArrayList();
            foreach (ReturnPo returnPo in legalReturnPOList)
            {
                if (!retNAPOId.Equals(returnPo.ReturnPoPK.PurchaseOrderId))
                {
                    if(!string.IsNullOrEmpty(retNAPOId))
                    {
                        collection.Add(retNAView);
                        retNAView = new PurchaseOrderView();
                        retNAView.ReturnPOList = new ArrayList();
                    }
                    retNAPOId = returnPo.ReturnPoPK.PurchaseOrderId;
                    retNAView.PurchaseOrderId = retNAPOId;
                    retNAView.IssueDate = returnPo.ReturnPoPK.CreateDate;
                }
                retNAView.ReturnDescription += returnPo.Product.ProductMaster.ProductName + " ";
                long retPrice = returnPo.Price;
                    if (retPrice == 0)
                    {
                        DepartmentPricePK deptPricePK = new DepartmentPricePK();
                        deptPricePK.DepartmentId = 0;
                        deptPricePK.ProductMasterId = returnPo.Product.ProductMaster.ProductMasterId;
                        DepartmentPrice price = DepartmentPriceLogic.FindById(deptPricePK);
                        if (price != null)
                        {
                            retPrice = price.Price;
                        }
                    }
                retNAView.ReturnAmount += returnPo.Quantity * retPrice;
                retNAView.ReturnQuantity += returnPo.Quantity;
                retNAView.ReturnPOList.Add(returnPo);
            }
            collection.Add(retNAView);

            GoodsSaleListEventArgs goodsSaleListEventArgs = new GoodsSaleListEventArgs();
            goodsSaleListEventArgs.PurchaseOrderViewList = collection;
            EventUtility.fireEvent(CompletedGoodsSaleListSearchEvent, this, goodsSaleListEventArgs);
        }
コード例 #6
0
 private void SearchGoods(object sender, GoodsSaleListEventArgs e)
 {
     IList list = PurchaseOrderLogic.FindAll(e.PurchaseOrderSearchCriteria);
     PurchaseOrderCollection collection = new PurchaseOrderCollection();
     foreach (PurchaseOrder order in list)
     {
         collection.Add(order);
     }
     GoodsSaleListEventArgs goodsSaleListEventArgs = new GoodsSaleListEventArgs();
     goodsSaleListEventArgs.PurchaseOrders = collection;
     EventUtility.fireEvent(CompletedGoodsSaleListSearchEvent, this, goodsSaleListEventArgs);
 }
コード例 #7
0
 void monthGoodsSaleListView_GoodsSaleListSearchEvent(object sender, GoodsSaleListEventArgs e)
 {
     SearchGoodsAndReturnsInRange(sender,e);
 }
コード例 #8
0
        private void FillForm()
        {
            Department department = CurrentDepartment.Get();
            txtDepartmentId.Text = department.DepartmentId.ToString().PadLeft(3,'0');
            txtDepartmentName.Text = department.DepartmentName;
            txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy");

            GoodsSaleListEventArgs goodsSaleListEventArgs = new GoodsSaleListEventArgs();
            goodsSaleListEventArgs.PurchaseOrderSearchCriteria = CreateCriteria();
            goodsSaleListEventArgs.FromDate = DateUtility.ZeroTime(DateTime.Now);
            goodsSaleListEventArgs.ToDate = DateTime.Now;
            EventUtility.fireEvent(GoodsSaleListSearchEvent, this, goodsSaleListEventArgs);
        }
コード例 #9
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     GoodsSaleListEventArgs goodsSaleListEventArgs = new GoodsSaleListEventArgs();
     goodsSaleListEventArgs.PurchaseOrderSearchCriteria = CreateCriteria();
     goodsSaleListEventArgs.FromDate = DateUtility.ZeroTime(dtpFromDate.Value);
     goodsSaleListEventArgs.ToDate = DateUtility.MaxTime(dtpToDate.Value);
     EventUtility.fireEvent(GoodsSaleListSearchEvent,this,goodsSaleListEventArgs);
 }