public int Saveinvoice(InvoiceModel model) { try { using (_context= new HSSNInventoryEntities() ) { var data = new Invoice() { InvoiceId = model.InvoiceId, InvoiceNumber = model.InvoiceNumber, InvoiceDate = model.InvoiceDate, GateEntryNo = model.GateEntryNo, GateEntryDate = model.GateEntryDate, VechileNumber = model.VechileNumber, DistributorId = model.DistributorId, Remarks = model.Remarks, DateOfEntry = model.DateOfEntry, CreatedBy = model.CreatedBy, CreatedDate = model.CreatedDate, ModifiedBy = model.ModifiedBy, ModifiedDate = model.ModifiedDate, TotalAmount = model.TotalAmount, }; _context.Entry(data).State=EntityState.Added; _context.SaveChanges(); return data.InvoiceId; } } catch (Exception) { throw; } }
private void btnsave_Click(object sender, EventArgs e) { var model = new InvoiceModel() { InvoiceNumber = Convert.ToInt32(txtInvoiceNumber.Text), InvoiceDate = dtInvoiceDate.Value, GateEntryNo = Convert.ToInt32(txtGateEntryNo.Text), GateEntryDate = dtGateentrydate.Value, VechileNumber = txtVechilenumber.Text, DistributorId = Convert.ToInt32(txtdealerid.Text), Remarks = txtRemarks.Text, DateOfEntry = Convert.ToDateTime(DateTime.Now.ToShortDateString()), CreatedBy = 1, CreatedDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()), ModifiedBy = 1, ModifiedDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()), TotalAmount = Convert.ToDecimal(txtTotalamount.Text), }; int Invoiceid=_invoiceService.Saveinvoice(model); var griddata = datafnuc(); _invoiceService.SaveInvoiceDetail(griddata, Invoiceid); RadMessageBox.Show("Invoice Transaction Completed Successfully"); grdFinancedispatchDetail.Rows.Clear(); grdFinancedispatchDetail.Refresh(); grdInvoceDetail.Rows.Clear(); grdInvoceDetail.Refresh(); ListViewDealer(); }