Exemplo n.º 1
0
        public bool Update(QuotationItem entity)
        {
            int productUnitId = GetProductUnitId((int)entity.Unit.Id.Value, entity.Product.Code.Value);

            if (productUnitId > 0)
            {
                string sqlUpdate = "Update QuotationItem " +
                                   " SET Price = @Price," +
                                   " UpdatedAt = @UpdatedAt" +
                                   " WHERE QuotationId = @QuotationId and ProductUnitId = @ProductUnitId";
                using (var connection = Connection)
                {
                    var rows = connection.Execute(sqlUpdate,
                                                  new
                    {
                        QuotationId   = (int)entity.Quotation.Id.Value,
                        ProductUnitId = productUnitId,
                        Price         = entity.Price.Value,
                        UpdatedAt     = DateTime.Now
                    });
                    return(rows > 0);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        private void DeleteItem_E(object obj)
        {
            try
            {
                if (SelectedItemId != null)
                {
                    //db.SaveChanges();
                    QuotationItem item = db.QuotationItems.Find((int)SelectedItemId);



                    currentContext.Post(t =>
                    {
                        if (item != null)
                        {
                            db.QuotationItems.Remove(item);
                            selectedQuotation.Items.Remove(item);
                            db.SaveChanges();
                        }
                        signal.Set();
                    }, null);

                    signal.WaitOne();
                    selectedQuotation.Items = selectedQuotation.Items;
                }
            }
            catch { }
        }
Exemplo n.º 3
0
 public Task <object> Handle(UpdateQuotationItemCommand command, CancellationToken cancellationToken)
 {
     if (!command.IsValid())
     {
         NotifyValidationErrors(command);
     }
     else
     {
         QuotationItem quotationItem = new QuotationItem
                                       (
             null,
             new Entities.Quotation(new Identity((uint)command.QuotationId), null, null, null),
             new Entities.Product(null, null, new Code(command.ProductCode), null, null, null, null, null),
             new Entities.Unit(new Identity((uint)command.UnitId), null),
             new Price(command.Price)
                                       );
         QuotationItemModel quotationItemModel = _QuotationItemRepository.GetByProperties(quotationItem);
         bool result = false;
         if (quotationItemModel == null)
         {
             result = false;
         }
         else
         {
             result = _QuotationItemRepository.Update(quotationItem);
         }
         if (!result)
         {
             _bus.RaiseEvent(new DomainNotification("Quotation", "Server error", NotificationCode.Error));
         }
         return(Task.FromResult(result as object));
     }
     return(Task.FromResult(false as object));
 }
        public Quotation GetQuotationVersionDetails(string custId, string version)
        {
            QuotationDataAccess obj             = new QuotationDataAccess();
            var                  result         = obj.GetQuotationVersionDetails(custId, version);
            Quotation            quotation      = new Quotation();
            List <QuotationItem> quotationItems = new List <QuotationItem>();

            foreach (DataRow dr in result.Rows)
            {
                //quotationItems = new List<QuotationItem>();
                QuotationItem quotationItem = new QuotationItem();
                quotationItem.Name        = dr["QuotationId"].ToString();
                quotationItem.IsItem      = Convert.ToBoolean(dr["IsItem"].ToString());
                quotationItem.ItemId      = Convert.ToInt32(dr["ItemId"]);
                quotationItem.Margin      = float.Parse(dr["ItemMargin"].ToString());
                quotationItem.Name        = dr["Name"].ToString();
                quotationItem.Quantity    = dr["Quantity"].ToString();
                quotationItem.Description = dr["Description"].ToString();
                quotationItem.UnitRate    = float.Parse(dr["UnitRate"].ToString());
                quotationItem.Total       = float.Parse(dr["Rate"].ToString());
                quotationItem.Unit        = dr["Unit"].ToString();
                quotationItems.Add(quotationItem);
            }
            quotation.GrossMargin = float.Parse(result.Rows[0]["GrossMargin"].ToString());
            quotation.Total       = float.Parse(result.Rows[0]["Total"].ToString());
            quotation.Version     = Convert.ToInt32(result.Rows[0]["VersionNumber"].ToString());
            quotation.Items       = quotationItems;
            return(quotation);
        }
Exemplo n.º 5
0
        public QuotationItemModel Add(QuotationItem entity)
        {
            int productUnitId = GetProductUnitId((int)entity.Unit.Id.Value, entity.Product.Code.Value);

            if (productUnitId > 0)
            {
                string sqlInsert = "INSERT INTO QuotationItem (QuotationId,ProductUnitId,Price,CreatedAt,UpdatedAt)"
                                   + " Values (@QuotationId,@ProductUnitId,@Price,@CreatedAt,@UpdatedAt);"
                                   + " SELECT * From QuotationItem Where Id = CAST(SCOPE_IDENTITY() as int)";
                using (var connection = Connection)
                {
                    var result = connection.QuerySingleOrDefault <QuotationItemModel>(sqlInsert,
                                                                                      new
                    {
                        QuotationId   = (int)entity.Quotation.Id.Value,
                        ProductUnitId = productUnitId,
                        Price         = entity.Price.Value,
                        CreatedAt     = DateTime.Now,
                        UpdatedAt     = DateTime.Now
                    });
                    return(result);
                }
            }
            return(null);
        }
Exemplo n.º 6
0
        public bool Delete(string quotationNo, DbTransaction parentTransaction)
        {
            var quotationdetailItem = new QuotationItem {
                QuotationNo = quotationNo
            };

            return(Delete(quotationdetailItem, parentTransaction));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            QuotationItem quotationitem = db.QuotationItems.Find(id);

            db.QuotationItems.Remove(quotationitem);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 8
0
        public ActionResult AddNewQuotationItemRow()
        {
            ViewBag.Parts = db.Parts.ToList();
            QuotationItem quotationItem = new QuotationItem()
            {
                Part = new Part(), Quantity = 1
            };

            return(PartialView("EditorTemplates/QuotationItem", quotationItem));
        }
Exemplo n.º 9
0
 public Object SaveQuotationItem(QuotationItem quotationItem, string quotationNumber)
 {
     if (quotationItem != null)
     {
         var qID = _context.Quotation.Where(x => x.QuotationNumber == quotationNumber).Select(y => y.QuotationId).FirstOrDefault();
         quotationItem.QuotationId = qID;
         _context.QuotationItem.Add(quotationItem);
         _context.SaveChanges();
     }
     return(quotationItem);
 }
Exemplo n.º 10
0
        private void ItemsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                grid = (sender as DataGrid);
                QuotationItem item = grid.SelectedItem as QuotationItem;

                vm.SelectedItemId = item.Id;
            }
            catch { }
        }
Exemplo n.º 11
0
 public ActionResult Edit([Bind(Include = "ID,PartID,QuotationID,Quantity,Taxable,Total")] QuotationItem quotationitem)
 {
     if (ModelState.IsValid)
     {
         db.Entry(quotationitem).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.QuotationID = new SelectList(db.Quotations, "ID", "Status", quotationitem.QuotationID);
     ViewBag.PartID      = new SelectList(db.Parts, "PartID", "Name", quotationitem.PartID);
     return(View(quotationitem));
 }
Exemplo n.º 12
0
        //Ajax POST /Quotation/SelectProduct
        public PartialViewResult SelectProduct(int PartID, int?index)
        {
            Part Part = db.Parts.Find(PartID);

            QuotationItem QuotationItem = new QuotationItem()
            {
                Part = Part, PartID = Part.PartID, Quantity = 1
            };

            ViewBag.Parts = db.Parts.ToList();
            return(PartialView("EditorTemplates/QuotationItem", QuotationItem));
        }
Exemplo n.º 13
0
        public List <QuotationItem> GetQuotationItem(string QuotationCode, SqlConnection connection)
        {
            List <QuotationItem> objQuotationItemList_VW = new List <QuotationItem>();

            string vComTxt1 = @"SELECT  [QuotationDetCode]
                                      ,[QuotationCode]
                                      ,[RequisitionDetCode]
                                      ,[RequisitionCode]
                                      ,a.[ProductCode]
                                      ,B.productId
	                                  ,B.productName
                                      ,[ProductType]
                                      ,dbo.fxn_FileName(ProductType) productcategory
                                      ,[Quantity]
                                      ,[QunatityMOUCode]
                                      ,dbo.fxn_FileName(QunatityMOUCode)  as  Mou
                                      ,[VATRate]
                                      ,[Rate]
                                      ,[TotalVAT]
                                  FROM [dbo].[LSP_PMS_QuotationItem]  A join pm_product B on A.productcode = B.productCode
                                        WHERE A.[QuotationCode]= '" + QuotationCode + "'";

            SqlCommand    objDbCommand1 = new SqlCommand(vComTxt1, connection);
            SqlDataReader dr;

            dr = objDbCommand1.ExecuteReader();
            while (dr.Read())
            {
                QuotationItem obj = new QuotationItem();
                obj.QuotationDetCode_PK = dr["QuotationDetCode"].ToString();
                obj.QuotationCode       = dr["QuotationCode"].ToString();
                obj.RequisitionDetCode  = dr["RequisitionDetCode"].ToString();
                obj.RequisitionCode     = dr["RequisitionCode"].ToString();
                obj.ProductCode         = dr["ProductCode"].ToString();
                obj.ProductID_VW        = dr["productId"].ToString();
                obj.ProductName_VW      = dr["productName"].ToString();
                obj.QunatityMOUCode     = Convert.ToInt16(dr["QunatityMOUCode"].ToString());
                obj.QunatityMOU_VW      = dr["Mou"].ToString();
                obj.Quantity            = Convert.ToDecimal(dr["Quantity"].ToString());
                obj.ProductType         = Convert.ToInt16(dr["ProductType"].ToString());
                obj.ProductCatagory_NM  = dr["productcategory"].ToString();
                obj.VATRate             = Convert.ToDecimal(dr["VATRate"].ToString());
                obj.Rate     = Convert.ToDecimal(dr["Rate"].ToString());
                obj.TotalVAT = Convert.ToDecimal(dr["TotalVAT"].ToString());
                obj.QuotationItemSpecificationList_VW = GetItemSpecifications(QuotationCode, connection, dr);
                objQuotationItemList_VW.Add(obj);
            }
            dr.Close();
            return(objQuotationItemList_VW);
        }
Exemplo n.º 14
0
        // GET: /QuotationItem/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            QuotationItem quotationitem = db.QuotationItems.Find(id);

            if (quotationitem == null)
            {
                return(HttpNotFound());
            }
            return(View(quotationitem));
        }
Exemplo n.º 15
0
        // GET: /QuotationItem/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            QuotationItem quotationitem = db.QuotationItems.Find(id);

            if (quotationitem == null)
            {
                return(HttpNotFound());
            }
            ViewBag.QuotationID = new SelectList(db.Quotations, "ID", "Status", quotationitem.QuotationID);
            ViewBag.PartID      = new SelectList(db.Parts, "PartID", "Name", quotationitem.PartID);
            return(View(quotationitem));
        }
Exemplo n.º 16
0
        public QuotationItemModel GetByProperties(QuotationItem entity)
        {
            string sql = "SELECT * FROM QuotationItem q" +
                         " JOIN ProductUnit pu ON q.ProductUnitId = pu.Id" +
                         " JOIN Product p On pu.ProductId = p.Id" +
                         " Where pu.UnitId =@UnitId and p.Code = @ProductCode and q.QuotationId = @QuotationId;";

            using (var connection = Connection)
            {
                var model = connection.QueryFirstOrDefault <QuotationItemModel>(sql,
                                                                                new
                {
                    UnitId      = (int)entity.Unit.Id.Value,
                    ProductCode = entity.Product.Code.Value,
                    QuotationId = (int)entity.Quotation.Id.Value
                });
                return(model);
            }
        }
Exemplo n.º 17
0
        public ActionResult AddQuotation(string quotationNo, Int16 itemID)
        {
            QuotationItem quotationItem = null;

            if (quotationNo == string.Empty || quotationNo == null || quotationNo == "STANDARD")
            {
                quotationItem = new QuotationItem();
            }
            else
            {
                quotationItem = new POSAccount.BusinessFactory.QuotationBO().GetQuotation(new Contract.Quotation {
                    QuotationNo = quotationNo
                })
                                .QuotationItems.Where(dt => dt.ItemID == itemID).FirstOrDefault();
                if (quotationItem == null)
                {
                    quotationItem = new QuotationItem();
                }
            }
            quotationItem.ChargeCodeList = Utility.GetChargeCodeItemList();
            return(PartialView("AddQuotationItem", quotationItem));
            //return PartialView("AddQuotationItem");
        }
Exemplo n.º 18
0
        private async void ItemsDataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            var grid = (sender as DataGrid);

            QuotationItem item = e.Row.Item as QuotationItem;

            tb = e.EditingElement as TextBox;
            try
            {
                if (e.Column.Header.ToString() == "QTY")
                {
                    double tbValue = Convert.ToDouble(tb.Text);
                    if (!string.IsNullOrEmpty(item.UnitCost))
                    {
                        item.TotalCost = tbValue * Convert.ToDouble(item.UnitCost);
                    }
                }
                else if (e.Column.Header.ToString() == "UnitCost")
                {
                    double tbValue = Convert.ToDouble(tb.Text);
                    if (!string.IsNullOrEmpty(item.QTY))
                    {
                        item.TotalCost = tbValue * Convert.ToDouble(item.QTY);
                    }
                }
            }
            catch
            {
                item.TotalCost = 0;
                MessageBox.Show("Please Use appopriate Values int the grid boxes", "Invalid Value", MessageBoxButton.OK, MessageBoxImage.Warning);
                tb.Text = "";
            }

            await GetTotalValues();

            vm.db.SaveChanges();
        }
Exemplo n.º 19
0
 public bool DeleteItem(QuotationItem item, DbTransaction parentTransaction)
 {
     return(Delete(item, parentTransaction));
 }
Exemplo n.º 20
0
 public QuotationItem GetQuotationItem(QuotationItem item)
 {
     return((QuotationItem)quotationitemDAL.GetItem <QuotationItem>(item));
 }
Exemplo n.º 21
0
 public bool DeleteQuotationItem(QuotationItem item)
 {
     return(quotationitemDAL.Delete(item));
 }
Exemplo n.º 22
0
 public void Create(QuotationItem QuotationItem)
 {
     _QuotationItemRepository.Add(QuotationItem);
     _unitOfWork.Commit();
 }
Exemplo n.º 23
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (selSuppllier.SupplierId == null && String.IsNullOrEmpty(cboCandidateSupplier.SelectedValue))
            {
                Page.ShowError("Selecione um fornecedor!");
                return;
            }

            if (datDeliveryDate.DateTime < DateTime.Now.Date)
            {
                Page.ShowError("A data de entrega deve ser maior que hoje!");
                return;
            }

            if (grdProductsQuotation.Rows.Count == 0)
            {
                return;
            }

            int supplierId = selSuppllier.SupplierId ?? Convert.ToInt32(cboCandidateSupplier.SelectedValue);

            var ucTotalAmount = grdProductsQuotation.FooterRow.FindControl <CurrencyField>("ucTotalAmount");

            //
            // Load Quotation
            //
            Quotation quotation = Page.Manager.GetQuotation(Page.PurchaseOrder.PurchaseOrderId, supplierId) ??
                                  new Quotation
            {
                CompanyId       = Page.Company.CompanyId,
                PurchaseOrderId = Page.PurchaseOrder.PurchaseOrderId,
                SupplierId      = supplierId,
                TotalPrice      = ucTotalAmount.CurrencyValue.Value,
                DeliveryDate    = datDeliveryDate.DateTime.Value
            };

            var quotationItems = new List <QuotationItem>();

            foreach (GridViewRow row in grdProductsQuotation.Rows)
            {
                var ucCurrFieldPrice    = (CurrencyField)row.FindControl("ucCurrFieldPrice");
                int purchaseOrderItemId = Convert.ToInt32(grdProductsQuotation.DataKeys[row.RowIndex]["PurchaseOrderItemId"]);

                QuotationItem originalQuotationItem = Page.Manager.GetQuotationItem(Page.Company.CompanyId,
                                                                                    supplierId,
                                                                                    purchaseOrderItemId,
                                                                                    Page.PurchaseOrder.PurchaseOrderId);

                var quotationItem = originalQuotationItem.Duplicate();
                quotationItem.CompanyId           = Page.Company.CompanyId;
                quotationItem.Price               = ucCurrFieldPrice.CurrencyValue.Value;
                quotationItem.SupplierId          = supplierId;
                quotationItem.PurchaseOrderItemId = purchaseOrderItemId;
                quotationItem.PurchaseOrderId     = Page.PurchaseOrder.PurchaseOrderId;

                quotationItems.Add(quotationItem);
            }

            //
            //caso a ordem de compra não estiver cadastrada
            //
            if (Page.PurchaseOrder.PurchaseOrderId == 0)
            {
                quotation.PurchaseOrderId = Page.SavePurchaseOrder().PurchaseOrderId;
            }

            Page.Manager.SaveQuotation(quotation, quotationItems, Page.Employee);
            Page.ViewState["_productList"] = Page.Manager.GetPurchaseOrderQuotedItems(
                Page.Company.CompanyId,
                Page.PurchaseOrder.PurchaseOrderId,
                PurchaseOrderDecision.LowUnitPrice);

            if (Page.PurchaseOrder.PurchaseOrderStatusId == PurchaseOrderStatus.Reproved ||
                Page.PurchaseOrder.PurchaseOrderStatusId == PurchaseOrderStatus.WaitingforApproval)
            {
                Page.ShowAlert("O processo não pode ser concluído e foi direcionado ao setor de compras para analise!");
            }

            foreach (QuotationItem item in quotationItems)
            {
                PurchaseOrderItem pItem = Page.Manager.GetPurchaseOrderItem(item.PurchaseOrderItemId);
                if (Page.PurchaseOrder.Quotations.Count() < 3 && pItem.ProductPackage.RequiresQuotationInPurchasing)
                {
                    Page.ShowAlert("Para este processo ser aprovado, necessita de 3 cotações ou mais!");
                }
            }
        }
Exemplo n.º 24
0
 public void Delete(QuotationItem QuotationItem)
 {
     _QuotationItemRepository.Delete(QuotationItem);
     _unitOfWork.Commit();
 }
Exemplo n.º 25
0
 public void Update(QuotationItem QuotationItem)
 {
     _QuotationItemRepository.Update(QuotationItem);
     _unitOfWork.Commit();
 }
Exemplo n.º 26
0
 public bool SaveQuotationItem(QuotationItem newItem)
 {
     return(quotationitemDAL.Save(newItem));
 }
Exemplo n.º 27
0
 public void Add(QuotationItem entity, int userId)
 {
 }