public void Delete(PurchaseOrderDetail data)
 {
     PurchaseOrderDetailDAO.Delete(data);
 }
 public void Update(PurchaseOrderDetail data)
 {
     PurchaseOrderDetailDAO.Update(data);
 }
 public PurchaseOrderDetail Add(PurchaseOrderDetail data)
 {
     PurchaseOrderDetailDAO.Add(data);
     return data;
 }
Exemplo n.º 4
0
 private PurchaseOrderDetail DumpNewRow(PurchaseOrderDetail detail)
 {
     PurchaseOrderDetail retDetail = new PurchaseOrderDetail();
     retDetail.PurchaseOrderDetailPK = detail.PurchaseOrderDetailPK;
     retDetail.Quantity = detail.Quantity;
     retDetail.Price = detail.Price;
     retDetail.ProductMaster = detail.ProductMaster;
     retDetail.Product = detail.Product;
     retDetail.PurchaseStatus = detail.PurchaseStatus;
     retDetail.PurchaseType = detail.PurchaseType;
     retDetail.CreateDate = detail.CreateDate;
     retDetail.DelFlg = detail.DelFlg;
     retDetail.DepartmentId = detail.DepartmentId;
     retDetail.ExclusiveKey = detail.ExclusiveKey;
     retDetail.PurchaseOrder = detail.PurchaseOrder;
     retDetail.PurchaseOrderDetailId = detail.PurchaseOrderDetailId;
     retDetail.PurchaseOrderId = detail.PurchaseOrderId;
     retDetail.PurchaseOrderPromotions = detail.PurchaseOrderPromotions;
     retDetail.Tax = detail.Tax;
     retDetail.UpdateDate = detail.UpdateDate;
     retDetail.UpdateId = detail.UpdateId;
     return retDetail;
 }
Exemplo n.º 5
0
 private void RemoveReturnPurchaseOrder(PurchaseOrderDetail detail, ref PurchaseOrderDetailCollection list, out int index)
 {
     for (int i = 0; i < list.Count; i++)
     {
         PurchaseOrderDetail orderDetail = list[i];
         if (orderDetail.PurchaseOrderDetailPK.PurchaseOrderDetailId == detail.PurchaseOrderDetailPK.PurchaseOrderDetailId
             && orderDetail.PurchaseOrderDetailPK.DepartmentId == detail.PurchaseOrderDetailPK.DepartmentId
             && orderDetail.PurchaseOrderDetailPK.PurchaseOrderId == detail.PurchaseOrderDetailPK.PurchaseOrderId
             )
         {
             list.RemoveAt(i);
             index = i;
             return;
         }
     }
     index = 0;
 }
Exemplo n.º 6
0
        private void btnInput_Click(object sender, EventArgs e)
        {
            if(GoodsSaleController.PurchaseOrder == null)
            {
                btnAdd_Click(null,e);
            }
            string deptId = string.Format("{0:000}", CurrentDepartment.Get().DepartmentId);
            GoodsSaleEventArgs eventArgs = new GoodsSaleEventArgs();
            PurchaseOrder searchRetPurchaseOrder = new PurchaseOrder();
            searchRetPurchaseOrder.PurchaseOrderPK = new PurchaseOrderPK
                                                                       {
                                                                           PurchaseOrderId = txtRefPurchaseOrder.Text,
                                                                           DepartmentId =
                                                                               CurrentDepartment.Get().DepartmentId
                                                                       };

            // if purchase order id is UNDEFINED
            if (!string.IsNullOrEmpty(txtRefPurchaseOrder.Text) && txtRefPurchaseOrder.Text.Trim().Equals("000"))
            {

                if (string.IsNullOrEmpty(txtRetProductName.Text) // product id is notavailable
                   && string.IsNullOrEmpty(txtRetBarCode.Text)) // bar code is not available
                {
                    MessageBox.Show(
                        "Nếu muốn trả hàng không đối chứng, xin nhập hoá đơn là 000 và chọn một mã vạch phù hợp.");
                    return;
                }

                //searchRetPurchaseOrder.PurchaseOrderPK.PurchaseOrderId = deptId + "UNDEF";
            }

            eventArgs.RefPurchaseOrder = searchRetPurchaseOrder;
            EventUtility.fireEvent(FindRefPurchaseOrder,this,eventArgs);

            PurchaseOrder retPurchaseOrder = eventArgs.RefPurchaseOrder;
            PurchaseOrderDetail retOrderDetail = null;
            if (retPurchaseOrder != null)
            {
                foreach (PurchaseOrderDetail orderDetail in retPurchaseOrder.PurchaseOrderDetails)
                {
                    if (orderDetail.Product.ProductId == txtRetBarCode.Text)
                    {
                        retOrderDetail = orderDetail;
                        break;
                    }
                }
            }
            if (retOrderDetail != null)
            {
                retOrderDetail.Quantity = Int64.Parse(txtRetQuantity.Text);
                retOrderDetail.Price = 0 - retOrderDetail.Price;
                pODList.Add(retOrderDetail);
                bdsBill.EndEdit();
                dgvBill.Refresh();
                dgvBill.Invalidate();

                GoodsSaleController.PurchaseOrder.PurchasePrice = CalculateTotalPrice(pODList);
                txtTotalAmount.Text = GoodsSaleController.PurchaseOrder.PurchasePrice.ToString();

                CreateRowNumbers();
                CalculateCharge();
                RemoveEmptyRowFromList(pODList);
                ClearReturnInput();
                ClearInput();
                txtBarcode.Focus();
            }
            else // in case undefined order
            {
                // if it's UNDEFINED purchase order
                if(!string.IsNullOrEmpty(txtRefPurchaseOrder.Text) && txtRefPurchaseOrder.Text.Trim().Equals("000"))
                {
                    // create new undefined order
                    PurchaseOrder undefPurchaseOrder = new PurchaseOrder();
                    undefPurchaseOrder.PurchaseOrderPK = new PurchaseOrderPK
                    {
                        PurchaseOrderId = txtRefPurchaseOrder.Text.Trim(),
                        DepartmentId =
                            CurrentDepartment.Get().DepartmentId
                    };
                    ReturnPurchaseOrder = undefPurchaseOrder;
                    // if defined barcode
                    /*if(!string.IsNullOrEmpty(txtRetProductName.Text))
                    {*/
                        PurchaseOrderDetail specialDetail = new PurchaseOrderDetail { Product = new Product()};
                        specialDetail.Product.ProductId = txtRetBarCode.Text;

                    if (!string.IsNullOrEmpty(specialDetail.Product.ProductId)
                            && specialDetail.Product.ProductId.Equals(CommonConstants.UNDEFINED_BARCODE_MARK))
                        {
                            specialDetail.Product.ProductId = string.Format("{0:000000000000}", 0);
                            if(CheckUtility.IsNullOrEmpty(txtRetPrice.Text))
                            {
                                /*MessageBox.Show("Xin hãy nhập giá của sản phẩm không có mã vạch");
                                return;*/
                            }
                            specialDetail.Price = Int64.Parse(txtRetPrice.Text);
                        }
                        try    // if null , will go to exception
                        {
                            GoodsSaleEventArgs goodsSaleEventArgs = new GoodsSaleEventArgs();
                            goodsSaleEventArgs.SelectedPurchaseOrderDetail = specialDetail;
                            goodsSaleEventArgs.NotAvailableInStock = true;
                            EventUtility.fireEvent(LoadGoodsEvent, this, goodsSaleEventArgs);

                            txtRetProductName.Text = goodsSaleEventArgs.SelectedPurchaseOrderDetail.Product.ProductMaster.ProductName;
                            txtRetPrice.Text = goodsSaleEventArgs.SelectedPurchaseOrderDetail.Price.ToString();
                            specialDetail = goodsSaleEventArgs.SelectedPurchaseOrderDetail;
                            specialDetail.PurchaseOrder = ReturnPurchaseOrder;
                            specialDetail.PurchaseOrderDetailPK = new PurchaseOrderDetailPK
                                                                      {
                                                                          DepartmentId = CurrentDepartment.Get().DepartmentId,
                                                                          PurchaseOrderId = ReturnPurchaseOrder.PurchaseOrderPK.PurchaseOrderId
                                                                      };
                            specialDetail.Quantity = 1;
                            specialDetail.Price = 0 - specialDetail.Price;
                            pODList.Add(specialDetail);
                            bdsBill.EndEdit();
                            dgvBill.Refresh();
                            dgvBill.Invalidate();
                        }
                        catch (Exception ex)
                        {
                            // do nothing
                            MessageBox.Show("Không có mã vạch này");
                        }
                        finally
                        {
                            GoodsSaleController.PurchaseOrder.PurchasePrice = CalculateTotalPrice(pODList);
                            txtTotalAmount.Text = GoodsSaleController.PurchaseOrder.PurchasePrice.ToString();

                            CreateRowNumbers();
                            CalculateCharge();
                            RemoveEmptyRowFromList(pODList);
                            ClearReturnInput();
                            ClearInput();
                            txtBarcode.Focus();
                        }
                    //}
                }
            }
        }
Exemplo n.º 7
0
 private bool ExistInList(PurchaseOrderDetailCollection newList,PurchaseOrderDetail detail, out PurchaseOrderDetail newDetail)
 {
     foreach (PurchaseOrderDetail orderDetail in newList)
     {
         if(orderDetail.ProductMaster.ProductName.Equals(detail.ProductMaster.ProductName))
         {
             newDetail = orderDetail;
             return true;
         }
     }
     newDetail = null;
     return false;
 }
 private long FindOriginAmount(IList details, PurchaseOrderDetail detail)
 {
     foreach (PurchaseOrderDetail orderDetail in details)
     {
         if(orderDetail.PurchaseOrderDetailPK.DepartmentId == detail.PurchaseOrderDetailPK.DepartmentId
           && orderDetail.PurchaseOrderDetailPK.PurchaseOrderId == detail.PurchaseOrderDetailPK.PurchaseOrderId
           && orderDetail.PurchaseOrderDetailPK.PurchaseOrderDetailId == detail.PurchaseOrderDetailPK.PurchaseOrderDetailId)
         {
             return orderDetail.Quantity;
         }
     }
     return 0;
 }
 /// <summary>
 /// Delete PurchaseOrderDetail from database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Delete(PurchaseOrderDetail data)
 {
     HibernateTemplate.Delete(data);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Add PurchaseOrderDetail to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public PurchaseOrderDetail Add(PurchaseOrderDetail data)
 {
     HibernateTemplate.Save(data);
     return data;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Update PurchaseOrderDetail to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Update(PurchaseOrderDetail data)
 {
     HibernateTemplate.Update(data);
 }
Exemplo n.º 12
0
 private long FindOriginAmount(PurchaseOrderDetail detail)
 {
     PurchaseOrderDetail originDetail = PurchaseOrderDetailDAO.FindById(detail.PurchaseOrderDetailPK);
     if(originDetail!=null)
     {
         return originDetail.Quantity;
     }
     return 0;
 }