public int saveData(FinanceDispatchModel model)
        {
            try
            {
                using (_context = new HSSNInventoryEntities())
                {
                    var addModel = new FinanceDispatch()
                    {
                        DispatchOrderId = model.DispatchOrderId,
                        EntryDate = model.EntryDate,
                        CreatedDate = model.CreatedDate,
                        CreatedBy = model.CreatedBy,

                    };
                    _context.Entry(addModel).State = EntityState.Added;
                    _context.SaveChanges();
                    model.FinanceDispatchId = addModel.FinanceDispatchId;

                    return model.FinanceDispatchId;
                }
            }
            catch (Exception e)
            {
                //Console.WriteLine(e);
                return 0;
            }
        }
        public bool EditData(MODEL.FinanceDispatchModel model)
        {
            try
            {
                using (_context = new HSSNInventoryEntities())
                {
                    var data =
                        _context.FinanceDispatches.FirstOrDefault(a => a.FinanceDispatchId == model.FinanceDispatchId);

                    data.DispatchOrderId = model.DispatchOrderId;
                    data.EntryDate       = model.EntryDate;
                    data.CreatedDate     = model.CreatedDate;
                    data.CreatedBy       = model.CreatedBy;


                    _context.Entry(data).State = EntityState.Modified;
                    _context.SaveChanges();

                    return(true);
                }
            }
            catch (Exception e)
            {
                //Console.WriteLine(e);
                return(false);
            }
        }
        private void btnApproved_Click(object sender, EventArgs e)
        {
            var model = new FinanceDispatchModel()
            {
                EntryDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()),
                DispatchOrderId = (int)LVDispatchOrder.SelectedItem.Value,
                CreatedBy = 1,
                CreatedDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()),
                ModifiedbY = 1,
                ModifiedDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()),

            };
            var model2 = new DispatchOrderModel()
            {
                DispatchOrderId = (int)LVDispatchOrder.SelectedItem.Value,
                WhetherDoApproved = true,
                ApprovedBy = 1,
            };
            _dispatchOrderService.EditDispatchOrderSumamry(model2);
            var griddata = datafnuc();
            var financeDispatchId = _fineDispatchService.saveData(model);
            _financeDispatchDetailService.SaveFinanceDispatchDetail(griddata, financeDispatchId);
            //_commonService.saveProductstockupdte(4, 2, 2, 5, "IN");
            Notify();
            grdDispatchOrderdetail.Rows.Clear();
            grdDispatchOrderdetail.Refresh();
            grdFinanceDetail.Rows.Clear();
            grdFinanceDetail.Refresh();
            ListviewDispatchOrder();


        }