public InvoiceDetailForm(InvoiceDetailModel model)
        {
            InitializeComponent();
            _presenter = new InvoiceDetailPresenter(this, model);

            this.Load += InvoiceDetailForm_Load;
        }
Beispiel #2
0
        private void UpdateCart(ProductViewModel data)
        {
            if (context.CartItems.Any(a => a.ProductId == data.Id))
            {
                //Item Exists


                foreach (InvoiceDetailModel item in context.CartItems)
                {
                    if (item.ProductId == data.Id)
                    {
                        item.QuantityInCart++;
                        item.Total = item.QuantityInCart * item.Rate;
                        item.OnPropertyChange("QuantityInCart");
                        item.OnPropertyChange("Total");
                    }
                }
                UpdateTotals(context.CartItems.Sum(a => a.Total));
            }
            else
            {
                var cartItem = new InvoiceDetailModel
                {
                    ProductId      = data.Id,
                    QuantityInCart = 1,
                    Name           = data.Name,
                    Rate           = data.Rate,
                    Barcode        = data.Barcode,
                    Total          = data.Rate
                };
                UpdateTotals(cartItem.Total);
                context.CartItems.Add(cartItem);
            }
        }
        private void BtnAddInvoiceDetail_Click(object sender, EventArgs e)
        {
            if (butonApasat != 1)
            {
                invoiceform.Show();

                List <InvoiceDetailModel> invoicedetail      = new List <InvoiceDetailModel>();
                InvoiceDetailModel        invoicedetailModel = new InvoiceDetailModel();
                invoicedetail = invoiceDetailModels;

                invoicedetailModel.InvoiceDetailId = 0;
                invoicedetailModel.InvoiceId       = invoiceform.InvoiceId;
                invoicedetailModel.Item            = new ItemModel
                {
                    ItemName = comboBoxItem.SelectedItem.ToString(),
                    ItemId   = Convert.ToInt32(comboBoxItem.SelectedIndex.ToString())
                };
                invoicedetailModel.Qtty         = Convert.ToDecimal(txtBoxQtty.Text);
                invoicedetailModel.Price        = Convert.ToDecimal(txtBoxPrice.Text);
                invoicedetailModel.Amount       = Convert.ToDecimal(txtBoxAmount.Text);
                invoicedetailModel.Observations = txtObservations.Text.ToString();
                invoicedetailModel.status       = 1;
                invoicedetail.Add(invoicedetailModel);
                invoiceform.refreshGrid(invoicedetail);

                butonApasat = 0;
                this.Close();
            }
            else
            {
                invoiceform.Show();

                List <InvoiceDetailModel> invoicedetail      = new List <InvoiceDetailModel>();
                InvoiceDetailModel        invoicedetailModel = new InvoiceDetailModel();
                invoicedetail = invoiceDetailModels;
                for (int i = 0; i < invoicedetail.Count; i++)
                {
                    if (invoicedetail[i].status == 2)
                    {
                        invoicedetailModel.InvoiceDetailId = 0;
                        invoicedetailModel.InvoiceId       = invoiceform.InvoiceId;
                        invoicedetailModel.Item            = new ItemModel
                        {
                            ItemName = comboBoxItem.SelectedItem.ToString(),
                            ItemId   = Convert.ToInt32(comboBoxItem.SelectedIndex.ToString())
                        };
                        invoicedetailModel.Qtty         = Convert.ToDecimal(txtBoxQtty.Text);
                        invoicedetailModel.Price        = Convert.ToDecimal(txtBoxPrice.Text);
                        invoicedetailModel.Amount       = Convert.ToDecimal(txtBoxAmount.Text);
                        invoicedetailModel.Observations = txtObservations.Text.ToString();
                        invoicedetailModel.status       = 2;

                        invoicedetail[i] = invoicedetailModel;
                        invoiceform.refreshGrid(invoicedetail);
                        butonApasat = 0;
                        this.Close();
                    }
                }
            }
        }
Beispiel #4
0
        public ActionResult AddinvoiceDetail(InvoiceDetailModel model)
        {
            var productModel = _productService.GetProductByCode(model.ProductCode);

            if (productModel == null)
            {
                return(Json(new
                {
                    IsProductSkusNotFound = true
                }));
            }

            if (_invoiceService.CheckProductExistedInInvoice(model.InvoiceId, productModel.Id))
            {
                return(Json(new
                {
                    IsDupp = true
                }));
            }

            model.ProductId = productModel.Id;
            model.Quantity  = model.Quantity;
            _invoiceService.InsertInvoiceDetail(model);
            return(Json(new { }));
        }
Beispiel #5
0
        public void InsertInvoiceDetail(InvoiceDetailModel invoiceDetailModel)
        {
            var invoiceDetail = Mapper.Map <InvoiceDetail>(invoiceDetailModel);

            _shoppingContext.InvoiceDetails.Add(invoiceDetail);
            _shoppingContext.SaveChanges();
        }
Beispiel #6
0
        public ActionResult ProductAddPopup(string btnId, string formId, int invoiceId, ProductListSelected request)
        {
            if (request.ProductIds != null)
            {
                if (!string.IsNullOrEmpty(request.ProductIds))
                {
                    var productIds = request.ProductIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var productId in productIds)
                    {
                        var id        = Int32.Parse(productId);
                        var isExisted = _invoiceService.CheckProductExistedInInvoice(invoiceId, id);
                        if (isExisted)
                        {
                            continue;
                        }
                        var product            = _productService.GetProductById(id);
                        var invoiceDetailModel = new InvoiceDetailModel()
                        {
                            Quantity  = 1,
                            ProductId = id,
                            InvoiceId = invoiceId,
                            UnitPrice = product.Price
                        };
                        _invoiceService.InsertInvoiceDetail(invoiceDetailModel);
                    }
                }
            }

            return(RedirectToAction("Edit", new { id = invoiceId }));
        }
Beispiel #7
0
        public static void UpdateInvoiceDetail(InvoiceDetailModel model)
        {
            InvoiceModel invoice = SessionHelper.Invoice;

            invoice.InvoiceDetail.FirstOrDefault(x => x.Id == model.Id).InvoiceSourceId = model.InvoiceSourceId;
            invoice.InvoiceDetail.FirstOrDefault(x => x.Id == model.Id).ItemId          = model.ItemId;
            invoice.InvoiceDetail.FirstOrDefault(x => x.Id == model.Id).Quantity        = model.Quantity;
            invoice.InvoiceDetail.FirstOrDefault(x => x.Id == model.Id).Rate            = model.Rate;
            invoice.InvoiceDetail.FirstOrDefault(x => x.Id == model.Id).TaxId           = model.TaxId;
            invoice.InvoiceDetail.FirstOrDefault(x => x.Id == model.Id).Amount          = model.Quantity * model.Rate;

            if (model.TaxId != null)
            {
                TaxDetailModel taxDetail = TaxHelper.GetTaxDetail(invoice.InvoiceDetail.FirstOrDefault(x => x.Id == model.Id).TaxId.ToString()).FirstOrDefault(x => x.StartDate <= SessionHelper.Invoice.InvoiceDate && x.EndDate >= SessionHelper.Invoice.InvoiceDate);

                if (taxDetail != null)
                {
                    invoice.InvoiceDetail.FirstOrDefault(x => x.Id == model.Id).TaxAmount = invoice.InvoiceDetail.FirstOrDefault(x => x.Id == model.Id).Amount *taxDetail.Rate / 100;
                }
                else
                {
                    invoice.InvoiceDetail.FirstOrDefault(x => x.Id == model.Id).TaxAmount = 0;
                }
            }
        }
Beispiel #8
0
        public void DeleteInvoiceDetail(InvoiceDetailModel detail)
        {
            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(Properties.Resources.ConnectionString);
                connection.Open();


                SqlCommand command = new SqlCommand("DeleteInvoiceDetail", connection);

                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.Parameters.Add(new SqlParameter("@InvoiceDetailId", detail.invoiceDetailId));

                command.ExecuteNonQuery();
                command.Parameters.Clear();
            }
            catch (SqlException se)
            {
                throw se;
            }

            finally
            {
                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }
        public void RefreshUpdate(InvoiceDetailModel detail)
        {
            List <InvoiceDetailModel> list = new List <InvoiceDetailModel>();

            for (int i = 0; i < dataGridDetails.Rows.Count; i++)
            {
                InvoiceDetailModel detailModel = new InvoiceDetailModel();
                detailModel = (InvoiceDetailModel)dataGridDetails.Rows[i].DataBoundItem;

                if (detailModel.InvoiceDetailId == detail.InvoiceDetailId)
                {
                    list.Add(detail);
                }
                else
                {
                    list.Add(detailModel);
                }
            }


            dataGridDetails.DataSource = list;
            dataGridDetails.Columns["InvoiceDetailId"].Visible = false;
            dataGridDetails.Columns["ItemId"].Visible          = false;
            dataGridDetails.Columns["InvoiceId"].Visible       = false;
            dataGridDetails.Columns["Status"].Visible          = false;
            dataGridDetails.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }
Beispiel #10
0
        public static void DeleteInvoiceDetail(InvoiceDetailModel model)
        {
            InvoiceModel       invoice       = SessionHelper.Invoice;
            InvoiceDetailModel invoiceDetail = invoice.InvoiceDetail.FirstOrDefault(x => x.Id == model.Id);

            invoice.InvoiceDetail.Remove(invoiceDetail);
        }
Beispiel #11
0
        public BindingList <InvoiceDetailModel> BLGetInvoiceDetail(int invoiceId, int?invoiceDetailId)
        {
            DAInvoiceDetail dac = new DAInvoiceDetail();
            DataTable       dt  = new DataTable();

            dt = dac.GetInvoiceDetail(invoiceId, invoiceDetailId);

            BindingList <InvoiceDetailModel> list = new BindingList <InvoiceDetailModel>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                InvoiceDetailModel detail = new InvoiceDetailModel();

                detail.invoiceDetailId = Convert.ToInt32(dt.Rows[i]["InvoiceDetailId"].ToString());
                detail.invoiceId       = Convert.ToInt32(dt.Rows[i]["InvoiceId"].ToString());
                detail.itemId          = Convert.ToInt32(dt.Rows[i]["itemId"].ToString());
                detail.itemName        = dt.Rows[i]["ItemName"].ToString();
                detail.qtty            = Convert.ToDecimal(dt.Rows[i]["Qtty"].ToString());
                detail.price           = Convert.ToDecimal(dt.Rows[i]["Price"].ToString());
                detail.amount          = Convert.ToDecimal(dt.Rows[i]["Amount"].ToString());
                detail.observation     = dt.Rows[i]["Observation"].ToString();
                detail.status          = 3;
                detail.unique          = detail.RandomString(8);

                list.Add(detail);
            }

            return(list);
        }
Beispiel #12
0
 public ActionResult UpdatePartial(InvoiceDetailModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (model.ItemId == null && model.InvoiceSourceId == null)
             {
                 ViewData["EditError"] = "Either Invoice Source or Item is required.";
             }
             else if (model.ItemId != null && model.InvoiceSourceId != null)
             {
                 ViewData["EditError"] = "Only Invoice Source or Item can be entered at a time.";
             }
             else
             {
                 InvoiceHelper.UpdateInvoiceDetail(model);
             }
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("_Detail", InvoiceHelper.GetInvoiceDetail()));
 }
        public void RefreshAdd(InvoiceDetailModel detail)
        {
            List <InvoiceDetailModel> list = new List <InvoiceDetailModel>();

            //BLAddress bLAddress = new BLAddress();
            for (int i = 0; i < dataGridDetails.Rows.Count; i++)
            {
                InvoiceDetailModel details = new InvoiceDetailModel();
                details = (InvoiceDetailModel)dataGridDetails.Rows[i].DataBoundItem;
                //addressModel.status = 1;
                list.Add(details);
            }

            //list = bLAddress.Address(id);
            //address.status = 1;
            //address.ClientAddressId = -1;

            list.Add(detail);
            //MessageBox.Show(address.ClientAddressId.ToString());
            dataGridDetails.DataSource = list;
            dataGridDetails.Columns["InvoiceDetailId"].Visible = false;
            dataGridDetails.Columns["ItemId"].Visible          = false;
            dataGridDetails.Columns["InvoiceId"].Visible       = false;
            dataGridDetails.Columns["Status"].Visible          = false;
            dataGridDetails.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }
        private void BtnAddDetail_Click(object sender, EventArgs e)
        {
            ItemModel item = (ItemModel)cmbItem.SelectedItem;

            //string itemName = item.ItemName;
            double             qtty          = Convert.ToDouble(txtQtty.Text);
            double             price         = Convert.ToDouble(txtUnitPrice.Text);
            double             amount        = Convert.ToDouble(txtAmount.Text);
            string             observations  = txtObservations.Text;
            InvoiceDetailModel invoiceDetail = new InvoiceDetailModel();

            invoiceDetail.Amount       = amount;
            invoiceDetail.ItemName     = item.ItemName;
            invoiceDetail.InvoiceId    = invoiceId;
            invoiceDetail.Qtty         = qtty;
            invoiceDetail.UnitPrice    = price;
            invoiceDetail.Observations = observations;
            invoiceDetail.Status       = 1;
            parent.RefreshAdd(invoiceDetail);
            parent.Refresh();
            parent.Show();
            this.Hide();

            parent.FormClosed += Parent_FormClosed;
        }
Beispiel #15
0
        public ActionResult SearchArticle(InvoiceDetailModel viewModel)
        {
            var strMessage = string.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    //var entity = viewModel.ToEntity();
                    //_invInvoiceService.BMSUnit.InvoiceRepository.Add(entity);
                    //_invInvoiceService.BMSUnit.InvoiceRepository.SaveChanges();

                    return(Content(Boolean.TrueString));
                    //return Content("Information has been saved successfully");
                }

                strMessage = Common.GetModelStateErrorMessage(ModelState);
            }
            catch (Exception ex)
            {
                strMessage = CommonExceptionMessage.GetExceptionMessage(ex, CommonAction.Save);
            }

            return(Content(strMessage));
        }
        private InvoiceDetailModel InitEditPanel()
        {
            InvoiceDetailModel detail = new InvoiceDetailModel();

            initializareComboBox();
            foreach (DataGridViewRow row in dataGridViewDetalii.SelectedRows)
            {
                tbAmount.Text          = row.Cells[5].Value.ToString();
                detail.InvoiceDetailId = Convert.ToInt32(row.Cells[0].Value.ToString());
                tbObservations.Text    = row.Cells[6].Value.ToString();
                tbPrice.Text           = row.Cells[4].Value.ToString();
                tbQtty.Text            = row.Cells[3].Value.ToString();
                tbAmount.Text          = ((Convert.ToDecimal(row.Cells[4].Value.ToString())) *
                                          (Convert.ToDecimal(row.Cells[3].Value.ToString()))).ToString();
                DataTable items   = new DataTable();
                BLItems   blItems = new BLItems();
                try
                {
                    items        = blItems.GetItemNameById(Convert.ToInt32(row.Cells[2].Value.ToString()));
                    cbItems.Text = items.Rows[0]["ItemName"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Eroare INIT PANEL!! " + ex.Message);
                }
            }
            return(detail);
        }
        private void BtnEditDetail_Click(object sender, EventArgs e)
        {
            InvoiceDetailModel detaliuModificat = new InvoiceDetailModel();
            BLInvoiceDetails   bLInvoiceDetails = new BLInvoiceDetails();

            try
            {
                detaliuModificat.InvoiceDetailId = this.EditDetailId;
                detaliuModificat.Price           = Convert.ToDecimal(tbPrice.Text);
                detaliuModificat.Qtty            = Convert.ToDecimal(tbQtty.Text);
                detaliuModificat.Amount          = Convert.ToDecimal(tbAmount.Text);
                detaliuModificat.Observations    = tbObservations.Text;
                detaliuModificat.Articol.ItemId  = Convert.ToInt32(cbItems.SelectedValue);
                DialogResult dialogResult = MessageBox.Show("Sigur doriti sa modificati detaliul?", "Modificare Detaliu Factura", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    bLInvoiceDetails.UpdateInvoiceDetail(detaliuModificat, out bool status, out string message);
                    MessageBox.Show(message, "Status", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    panel1.Visible = false;
                    initializareDataGrid(this.factura.InvoiceId);
                }
                else if (dialogResult == DialogResult.No)
                {
                    this.Hide();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("EROARE UPDATE DETAIL! " + ex.Message);
            }
        }
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            InvoiceDetailModel detaliu   = new InvoiceDetailModel();
            BLInvoiceDetails   blInvoice = new BLInvoiceDetails();

            if (String.IsNullOrWhiteSpace(tbPrice.Text))
            {
                errorProvider1.SetError(tbPrice, "Camp obligatoriu!");
            }
            else if (String.IsNullOrWhiteSpace(tbQtty.Text))
            {
                errorProvider1.SetError(tbPrice, "Camp obligatoriu!");
            }
            else
            {
                try
                {
                    detaliu.Price             = Convert.ToDecimal(tbPrice.Text);
                    detaliu.Qtty              = Convert.ToDecimal(tbQtty.Text);
                    detaliu.Amount            = Convert.ToDecimal(tbAmount.Text);
                    detaliu.Observations      = tbObservations.Text;
                    detaliu.Factura.InvoiceId = factura.InvoiceId;
                    detaliu.Articol.ItemId    = Convert.ToInt32(cbItems.SelectedValue);
                    blInvoice.InsertInvoiceDetail(detaliu, out bool status, out string message);
                    MessageBox.Show(message, "Status", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    panel1.Visible = false;
                    initializareDataGrid(this.factura.InvoiceId);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("EROARE INSERARE DETALIU! " + ex.Message);
                }
            }
        }
Beispiel #19
0
        private void Button1_Click_1(object sender, EventArgs e)
        {
            AddInvoiceDetailForm addInvoice = new AddInvoiceDetailForm(this);

            addInvoice.butonApasat = 1;
            addInvoice.Show();
            this.Hide();
            if (Convert.ToInt32(dGVInvoiceDetails.SelectedRows[0].Cells[7].Value) == 1)
            {
                dGVInvoiceDetails.SelectedRows[0].Cells[7].Value = 1;
            }
            else
            {
                dGVInvoiceDetails.SelectedRows[0].Cells[7].Value = 2;
            }

            List <InvoiceDetailModel> invoiceDetailModels = new List <InvoiceDetailModel>();

            for (int i = 0; i < dGVInvoiceDetails.RowCount; i++)
            {
                InvoiceDetailModel invoicedetail = new InvoiceDetailModel();
                invoicedetail = (InvoiceDetailModel)dGVInvoiceDetails.Rows[i].DataBoundItem;
                invoiceDetailModels.Add(invoicedetail);
            }
            addInvoice.invoiceDetailModels = invoiceDetailModels;

            addInvoice.txtBoxPrice.Text     = dGVInvoiceDetails.SelectedRows[0].Cells[5].Value.ToString();
            addInvoice.txtBoxAmount.Text    = dGVInvoiceDetails.SelectedRows[0].Cells[4].Value.ToString();
            addInvoice.txtBoxQtty.Text      = dGVInvoiceDetails.SelectedRows[0].Cells[3].Value.ToString();
            addInvoice.txtObservations.Text = dGVInvoiceDetails.SelectedRows[0].Cells[6].Value.ToString();
        }
Beispiel #20
0
        private static InvoiceDetail getEntityByModel(InvoiceDetailModel model)
        {
            if (model == null)
            {
                return(null);
            }
            InvoiceDetail entity = new InvoiceDetail();

            if (model.Id == 0)
            {
                entity.CreateBy   = AuthenticationHelper.UserId;
                entity.CreateDate = DateTime.Now;
            }
            else
            {
                entity.CreateBy   = model.CreateBy;
                entity.CreateDate = model.CreateDate;
            }

            entity.Amount          = model.Amount;
            entity.Id              = model.Id;
            entity.InvoiceId       = model.InvoiceId;
            entity.InvoiceSourceId = model.InvoiceSourceId;
            entity.ItemId          = model.ItemId;
            entity.Quantity        = model.Quantity;
            entity.Rate            = model.Rate;
            entity.TaxAmount       = model.TaxAmount;
            entity.TaxId           = model.TaxId;
            entity.UpdateBy        = AuthenticationHelper.UserId;
            entity.UpdateDate      = DateTime.Now;
            return(entity);
        }
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            if (dataGridViewItems.Rows.Count != 0)
            {
                int i = dataGridViewItems.SelectedCells[0].RowIndex;
                int selectedInvoiceDetailId = Convert.ToInt32(dataGridViewItems.Rows[i].Cells[0].Value.ToString());
                InvoiceDetailModel iv       = new InvoiceDetailModel()
                {
                    invoiceDetailId = selectedInvoiceDetailId,
                    invoiceId       = invoiceIdSelected,
                    itemId          = Convert.ToInt32(dataGridViewItems.Rows[i].Cells[2].Value.ToString()),
                    itemName        = dataGridViewItems.Rows[i].Cells[3].Value.ToString(),
                    qtty            = Convert.ToDecimal(dataGridViewItems.Rows[i].Cells[4].Value.ToString()),
                    price           = Convert.ToDecimal(dataGridViewItems.Rows[i].Cells[5].Value.ToString()),
                    amount          = Convert.ToDecimal(dataGridViewItems.Rows[i].Cells[6].Value.ToString()),
                    observation     = dataGridViewItems.Rows[i].Cells[7].Value.ToString(),
                    status          = 2,
                    unique          = dataGridViewItems.Rows[i].Cells[9].Value.ToString()
                };

                if (listDetail.Count == 0)
                {
                    listDetail.Add(iv);
                }
                else
                {
                    foreach (InvoiceDetailModel model in listDetail)
                    {
                        if (model.unique == iv.unique && model.invoiceDetailId != 0)
                        {
                            model.status = 2;
                            break;
                        }
                        else if (model.unique == iv.unique && model.invoiceDetailId == 0)
                        {
                            listDetail.Remove(model);
                            break;
                        }
                        else if (iv.invoiceDetailId != 0)
                        {
                            listDetail.Add(iv);
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }

                dataGridViewItems.Rows.RemoveAt(i);
            }
            else
            {
                MessageBox.Show("Nu se poate sterge niciun detaliu de factura deoarece nu exista niciunul", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
        public void AddItemToDataGridViewAndList(InvoiceDetailForm iva)
        {
            InvoiceDetailModel detail = iva.GetInvoiceDetail();

            if (!iva.IsAddedorModify())
            {
                changeDataGridView = false;
            }
            if (detail.status == 0)
            {
                dataGridViewItems.Rows.Add(detail.invoiceDetailId, detail.invoiceId, detail.itemId, detail.itemName, detail.qtty, detail.price, detail.amount, detail.observation, detail.status, detail.unique);
                listDetail.Add(detail);
            }
            else if (detail.status == 1)
            {
                foreach (DataGridViewRow row in dataGridViewItems.Rows)
                {
                    if (row.Cells[9].Value.ToString() == detail.unique.ToString() && row.Cells[0].Value.ToString() == detail.invoiceDetailId.ToString())
                    {
                        row.Cells[2].Value = detail.itemId.ToString();
                        row.Cells[3].Value = detail.itemName.ToString();
                        row.Cells[4].Value = detail.qtty.ToString();
                        row.Cells[5].Value = detail.price.ToString();
                        row.Cells[6].Value = detail.amount.ToString();
                        row.Cells[7].Value = detail.observation.ToString();
                        row.Cells[8].Value = detail.status.ToString();

                        bool verifyList = listDetail.Any(item => item.unique == detail.unique && item.invoiceDetailId == detail.invoiceDetailId);
                        if (!verifyList)
                        {
                            listDetail.Add(detail);
                        }
                        else
                        {
                            foreach (InvoiceDetailModel model in listDetail)
                            {
                                if (model.unique == detail.unique && model.invoiceDetailId == detail.invoiceDetailId)
                                {
                                    model.itemId      = detail.itemId;
                                    model.itemName    = detail.itemName;
                                    model.qtty        = detail.qtty;
                                    model.price       = detail.price;
                                    model.amount      = detail.amount;
                                    model.observation = detail.observation;

                                    break;
                                }
                            }
                        }


                        break;
                    }
                }
            }
        }
Beispiel #23
0
        public void UpdateInvoiceDetail(InvoiceDetailModel det, out bool status, out string errorMessage)
        {
            status       = false;
            errorMessage = "OK";
            DAInvoiceDetails da = new DAInvoiceDetails();

            da.UpdateInvoiceDetail(det);

            errorMessage = "Detaliu modificat!";
        }
Beispiel #24
0
        public void InsertInvoiceDetail(InvoiceDetailModel det, out bool status, out string errorMessage)
        {
            status       = false;
            errorMessage = "OK";
            DAInvoiceDetails da = new DAInvoiceDetails();

            da.InsertInvoiceDetail(det);

            errorMessage = "Detaliu adaugat!";
        }
 public InvoiceDetailsSubmitViewModel(InvoiceDetailModel invoice, INavigation navigation)
 {
     IsReturn          = true;
     _navigation       = navigation;
     submitCommand     = new Command(async() => await submitInvoiceCommand());
     isRefundCommand   = new Command <bool>(setIsRefund);
     isReturnCommand   = new Command <bool>(setIsReturn);
     invoiceDetail     = invoice;
     _IAllDataServices = new AllDataServices();
 }
Beispiel #26
0
        private void BtnAddInvoice_Click(object sender, EventArgs e)
        {
            InvoiceId += 1;
            if (String.IsNullOrWhiteSpace(txtBoxInvoiceNumber.Text))
            {
                MessageBox.Show("Numarul facturii nu este completat!", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(comboBoxClient.Text))
            {
                MessageBox.Show("Nu este ales nciun partenere!", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(comboBoxClientAddress.Text))
            {
                MessageBox.Show("Nu este ales nciun partenere!", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (dateInvoiceDate.Text.Length == 0)
            {
                MessageBox.Show("Nu ai ales data!", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DATotCeFolosescLaInvoice invoice = new DATotCeFolosescLaInvoice();
            string   numarfactura            = txtBoxInvoiceNumber.Text;
            DateTime dataFactura             = dateInvoiceDate.Value.Date;
            int      idpar    = ((ClientModel)comboBoxClient.SelectedItem).ClientId;
            int      idadresa = ((ClientAddressModel)comboBoxClientAddress.SelectedItem).ClientAddressId;
            string   obser    = txtBoxObservations.Text;


            List <InvoiceDetailModel> invoiceDetailModels = new List <InvoiceDetailModel>();

            for (int i = 0; i < dGVInvoiceDetails.RowCount; i++)
            {
                InvoiceDetailModel invoicedetail = new InvoiceDetailModel();
                invoicedetail = (InvoiceDetailModel)dGVInvoiceDetails.Rows[i].DataBoundItem;
                invoiceDetailModels.Add(invoicedetail);
            }

            bool status = invoice.insertInvoice(numarfactura, dataFactura, idpar, idadresa, UserId, obser, invoiceDetailModels);

            if (status == true)
            {
                MessageBox.Show("Factura adaugata!", "Wew", MessageBoxButtons.OK, MessageBoxIcon.Information);
                InvoicesForm invoicesForm = new InvoicesForm();
                invoicesForm.Show();
                this.Hide();
                invoicesForm.FormClosed += invoice_from_formClosed;
            }
            else
            {
                MessageBox.Show("Factura neadaugata!", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public async Task <IActionResult> SearchAllInvoices([FromBody] InvoiceDetailModel model)
 {
     try
     {
         dynamic response = await new InvoiceManager().SearchAllInvoices(model);
         return(Ok(response));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        private void Save(int invoiceId, int userId)
        {
            BLInvoice       bLInvoice       = new BLInvoice();
            BLInvoiceDetail bLInvoiceDetail = new BLInvoiceDetail();

            if (userId != 0 & invoiceId == 0)
            {
                string              invoiceNumber  = txtInvoiceNumber.Text;
                DateTime            invoiceDate    = dateInvoice.Value;
                ClientFullNameModel clientFullName = (ClientFullNameModel)cmbClientFullName.SelectedItem;
                FullAddressModule   fullAddress    = (FullAddressModule)cmbAddress.SelectedItem;
                if (fullAddress == null)
                {
                    MessageBox.Show("Clientul nu are o adresa, adaugati o adresa clientului pentru a creea o factura!");
                    return;
                }
                int    clientId        = clientFullName.ClientId;
                int    clientAddressId = fullAddress.ClientAddressId;
                string observations    = txtObservations.Text;

                MessageBox.Show(clientAddressId.ToString());

                bLInvoice.AddInvoice(invoiceNumber, invoiceDate, clientId, clientAddressId, userId, observations);
                MessageBox.Show("Factura a fost adaugata cu succes.");
                int invoiceIdValue = bLInvoice.GetInvoiceList(-1, "", DateTime.Now, DateTime.Now, invoiceNumber)[0].InvoiceId;
                Save(invoiceIdValue, 0);
            }
            if (userId == 0 & invoiceId != 0)
            {
                for (int i = 0; i < dataGridDetails.Rows.Count; i++)
                {
                    InvoiceDetailModel detail = new InvoiceDetailModel();
                    detail = (InvoiceDetailModel)dataGridDetails.Rows[i].DataBoundItem;
                    if (detail.Status == 1)
                    {
                        bLInvoiceDetail.AddDetail(invoiceId, detail.ItemName, detail.Qtty, detail.UnitPrice, detail.Amount, detail.Observations);
                    }
                    //INSERT
                    if (detail.Status == 2)
                    {
                        bLInvoiceDetail.UpdateDetail(invoiceId, detail.InvoiceDetailId, detail.ItemName, detail.Qtty, detail.UnitPrice, detail.Amount, detail.Observations);
                    }



                    //UPDATE
                    if (detail.Status == 3)
                    {
                        bLInvoiceDetail.DeleteDetail(invoiceId, detail.InvoiceDetailId);
                    }
                }
            }
        }
Beispiel #29
0
        public void UpdateInvoiceDetail(InvoiceDetailModel invoiceDetailModel)
        {
            var invoiceDetail = _shoppingContext.InvoiceDetails.Find(invoiceDetailModel.Id);

            if (invoiceDetail == null)
            {
                return;
            }
            invoiceDetail = Mapper.Map <InvoiceDetail>(invoiceDetailModel);
            _shoppingContext.InvoiceDetails.AddOrUpdate(invoiceDetail);
            _shoppingContext.SaveChanges();
        }
Beispiel #30
0
        private void DGVInvoices_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            InvoiceForm invoiceForm = new InvoiceForm();

            invoiceForm.Show();
            this.Hide();

            int             index       = e.RowIndex;
            DataGridViewRow selectedRow = dGVInvoices.Rows[index];

            invoiceForm.UserId = Convert.ToInt32(selectedRow.Cells[1].Value);
            invoiceForm.txtBoxInvoiceNumber.Text    = selectedRow.Cells[1].Value.ToString();
            invoiceForm.txtBoxObservations.Text     = selectedRow.Cells[6].Value.ToString();
            invoiceForm.comboBoxClient.SelectedItem = selectedRow.Cells[3].Value.ToString();
            invoiceForm.comboBoxClientAddress.Text  = selectedRow.Cells[4].Value.ToString();
            invoiceForm.dateInvoiceDate.Value       = Convert.ToDateTime(selectedRow.Cells[4].Value);

            DATotCeFolosescLaInvoice detalii = new DATotCeFolosescLaInvoice();
            DataTable dt = new DataTable();

            dt = detalii.getInvoiceDetails(Convert.ToInt32(selectedRow.Cells[0].Value));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                InvoiceDetailModel invoicemode = new InvoiceDetailModel();
                invoicemode.InvoiceId       = Convert.ToInt32(dt.Rows[i]["InvoiceId"].ToString());
                invoicemode.InvoiceDetailId = Convert.ToInt32(dt.Rows[i]["InvoiceDetailId"].ToString());
                invoicemode.Item            = new ItemModel
                {
                    ItemName = dt.Rows[i]["Item"].ToString()
                };
                invoicemode.Qtty         = Convert.ToDecimal(dt.Rows[i]["Qtty"].ToString());
                invoicemode.Price        = Convert.ToDecimal(dt.Rows[i]["Price"].ToString());
                invoicemode.Amount       = Convert.ToDecimal(dt.Rows[i]["Amount"].ToString());
                invoicemode.Observations = dt.Rows[i]["Observations"].ToString();

                //invoiceForm.lista.Add(invoicemode);
            }

            invoiceForm.dGVInvoiceDetails.DataSource = detalii.getInvoiceDetails(Convert.ToInt32(selectedRow.Cells[0].Value));
            invoiceForm.dGVInvoiceDetails.Columns["InvoiceDetailId"].Visible = false;
            invoiceForm.dGVInvoiceDetails.Columns["InvoiceId"].Visible       = false;
            invoiceForm.dGVInvoiceDetails.Columns["Item"].HeaderText         = "Item";
            invoiceForm.dGVInvoiceDetails.Columns["Qtty"].HeaderText         = "Cantitate";
            invoiceForm.dGVInvoiceDetails.Columns["Price"].HeaderText        = "Pret";
            invoiceForm.dGVInvoiceDetails.Columns["Amount"].HeaderText       = "Amount";
            invoiceForm.dGVInvoiceDetails.Columns["Observations"].HeaderText = "Observatii";

            invoiceForm.FormClosed += ClientDetail_Form_Closed;
        }