public int saveJobOrder(MODEL.JobOrderModel model)
 {
     try
     {
         using (_context = new HSSNInventoryEntities())
         {
             var data = new JobOrder()
             {
                 JobOrderNumber = model.JobOrderNumber,
                 JobOrderId     = model.JobOrderId,
                 JobOrderDate   = model.JobOrderDate,
                 DealerId       = model.DealerId,
                 Description    = model.Description,
                 PreparedBy     = model.PreparedBy,
                 IsApproved     = model.IsApproved,
                 ApprovedBy     = model.ApprovedBy,
                 ModifiedBy     = model.ModifiedBy,
                 ModifiedDate   = model.ModifiedDate,
             };
             _context.Entry(data).State = EntityState.Added;
             _context.SaveChanges();
             return(data.JobOrderId);
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
         throw;
     }
 }
        public int editJobOrder(JobOrderModel model)
        {
            try
            {

                using (_context = new HSSNInventoryEntities())
                {
                    var editModel = _context.JobOrders.FirstOrDefault(a => a.JobOrderId == model.JobOrderId);
                    if (editModel != null)
                    {

                        //editModel.DealerId = model.DealerId;
                        //editModel.JobOrderDate = model.JobOrderDate;
                        //editModel.Description = model.Description;
                        //editModel.PreparedBy = model.PreparedBy;
                        editModel.IsApproved = model.IsApproved;
                        editModel.ApprovedBy = model.ApprovedBy;
                        //editModel.ModifiedDate = model.ModifiedDate;
                        //editModel.ApprovedDate = model.ApprovedDate;

                    }
                    _context.Entry(editModel).State = EntityState.Modified;
                    _context.SaveChanges();
                    return model.JobOrderId;
                }

            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return 0;

            }
        }
        private void btnApproved_Click(object sender, EventArgs e)
        {
            var model = new JobOrderModel()
            {
                JobOrderId = Convert.ToInt32( LVJOBOrder.SelectedItem.Value),
                IsApproved = Convert.ToBoolean( 1),
                ApprovedBy = 1,

            };
            _jobOrder.editJobOrder(model);
            RadMessageBox.Show("Verification Completed");
            grdJobOrder.Rows.Clear();
            grdJobOrder.Refresh();
               // LVJOBOrder.Items.Clear();
            ListView();
        }
        private void btnsave_Click(object sender, EventArgs e)
        {
            if (validation()==true)
            {
                var model = new JobOrderModel()
                {
                    JobOrderId = JOBorderID,
                    JobOrderNumber = Convert.ToInt32(txtJobOrderNo.Text),
                    DealerId = Convert.ToInt32(cmbDealer.SelectedValue),
                    JobOrderDate = dtbJobOrderdate.Value,
                    Description = txtDescription.Text,
                    PreparedBy = Convert.ToInt32(txtPreparedBy.Text),

                };
                var griddata = datafunc();
                if (model.JobOrderId == 0)
                {
                    var joborderid = _jobOrderService.saveJobOrder(model);
                    _jobOrderService.savejoborderdetail(griddata, joborderid);
                    RadMessageBox.Show("Saved");
                    _commonService.UpdateSerialNumberVoucherType("JON");
                }
                else
                {
                    var JID = _jobOrderService.editJobOrder(model);
                    _jobOrderService.DeleteDetail(JID);
                    _jobOrderService.savejoborderdetail(griddata, JID);
                }

            }
        }