partial void DeleteInvoice(Invoice instance);
partial void InsertInvoice(Invoice instance);
partial void UpdateInvoice(Invoice instance);
public int Insert(DeliveryModel.OrdersModel item) { s26webDataContext db = new s26webDataContext(); try { Orders orders = new Orders { VolunteersId = item.VolunteersId, Osid = DateTime.UtcNow.AddHours(8).ToString("yyyyMMddHHmm"), ProductId = item.ProductId, Order_Quantity = item.Order_Quantity, TotalPrice = item.TotalPrice, Name = item.Name, Mobile = item.Mobile, CityId = item.CityId, AreaId = item.AreaId, Address = item.Address, SharePoint= true, Remarks = item.Remarks, OrdersStates = 22, OrdersTime = DateTime.UtcNow, ReciveTimeChoice = 15, OrdersFrom = 0, }; db.Orders.InsertOnSubmit(orders); db.SubmitChanges(); Invoice invoice = new Invoice { OrdersId = db.Orders.OrderByDescending(o => o.Id).FirstOrDefault(f => f.Id != null).Id, InvoiceCategory = item.InvoiceCategory }; if (item.InvoiceCategory == db.Category.FirstOrDefault(w => w.Fun_Id == 5 && w.Memo.Equals("Invoice")).Id) { invoice.InvoiceName = item.InvoiceName; invoice.InvoiceNo = item.InvoiceNo; } db.Invoice.InsertOnSubmit(invoice); db.SubmitChanges(); db.Connection.Close(); return orders.Id; } catch { return -1; } }