partial void Insertdelivery(delivery instance) { instance.timeStampCreated = DateTime.Now; instance.docType = "DL"; this.ExecuteDynamicInsert(instance); }
static void Main(string[] args) { DeliveryDAO da = new DeliveryDAO(); delivery del = new delivery(); // ConnectionFactory.setConnection("mysql", "127.0.0.1", "vbadb", "root", "root"); del.iddeliveryId = 32; delivery x = da.getDlivery(del); ICollection <deliverypart> b = x.deliveryparts; int a = 2; // var a = new DeliveryDAO(); // a.add(); /** deliverypart delpart = new deliverypart(); * delpart.id = 10; * delpart.deliverypartName ="fdfdf"; * * deliverypart delpart2 = new deliverypart(); * delpart2.id = 10; * delpart2.deliverypartName = "fdfdf"; * delivery xi = new delivery(); * object obj = new[] { delpart2, delpart };**/ /** var strings = ((IEnumerable)obj).Cast<object>() * .Select(x => x == null ? x : x.ToString()) * .ToArray(); * string[] mm=strings.Select(x2 => x2.ToString()).ToArray();**/ // string kk = strings.ToList<string>(); //double []m=x.LoadComObjectIntoDoubleArray(obj); // deliverypart[] strings = ((IEnumerable)obj).Cast<object>() // .Select(x => (deliverypart)x) // .ToArray(); }
protected void btn_save_Click(object sender, EventArgs e) { pnl_del.Visible = false; pnl_ord.Visible = true; btn_edit.Visible = true; img_del.Visible = true; delivery dl = new delivery { uname = txt_uname.Text, umobileno = Convert.ToInt64(txt_umobileno.Text), pincode = Convert.ToInt64(txt_pincode.Text), locality = txt_locality.Text, address = txt_add.Text, city = ddl_city.SelectedItem.Value, state = ddl_state.SelectedItem.Value, landmark = txt_landmark.Text, altumobileno = Convert.ToInt64(txt_altumobileno.Text), }; x.deliveries.InsertOnSubmit(dl); x.SubmitChanges(); Session["uname"] = txt_uname.Text; Session["add"] = txt_add.Text; Session["mobile"] = txt_umobileno.Text; //lbl_net.Text = Session["net"].ToString(); }
public ActionResult DeleteConfirmed(int id) { delivery delivery = db.deliveries.Find(id); db.deliveries.Remove(delivery); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,OrderID,EmployeeID,DeliveryDate,ChallanNo,DeliveredProducts,BalanceOrder,CreatedDate,CreatedBy,ModifiedDate,ModifiedBy")] delivery delivery) { if (ModelState.IsValid) { db.Entry(delivery).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OrderID = new SelectList(db.orders, "ID", "OrderNo", delivery.OrderID); return(View(delivery)); }
public ActionResult Create(delivery delivery) { delivery.orderdelivery_id = deliveryDAO.getDeliveryForCreate(WebSecurity.CurrentUserId); delivery.cost = 200; delivery.delivery_type = "доставка на дом"; delivery.delivery_status = "в магазине"; db.delivery.Add(delivery); db.SaveChanges(); db.Entry(delivery).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
// GET: Deliveries/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } delivery delivery = db.deliveries.Find(id); if (delivery == null) { return(HttpNotFound()); } return(View(delivery)); }
// GET: Deliveries/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } delivery delivery = db.deliveries.Find(id); if (delivery == null) { return(HttpNotFound()); } ViewBag.OrderID = new SelectList(db.orders, "ID", "OrderNo", delivery.OrderID); return(View(delivery)); }
public bool deleteDelivery(int id) { int idDel = (from c in _entities.delivery where c.orderdelivery_id == id select c.delivery_id).FirstOrDefault(); try { delivery delivery = _entities.delivery.Find(idDel); _entities.delivery.Remove(delivery); _entities.SaveChanges(); } catch { return(false); } return(true); }
private void createDeliveryRecord() { using (WebDL.Team2_BookDBEntities bke = new Team2_BookDBEntities()) { delivery deli = new delivery(); deli.userID = userId; deli.ordersID = orderID; deli.deliveryDate = Convert.ToDateTime(txtDeliveryDate.Text); deli.deliveryStatus = "pending"; deli.deliveryAddress = lbDeliveryAddress.Text; deli.deliveryDescription = txtDeliveryDescrip.Text; bke.deliveries.Add(deli); bke.SaveChanges(); } }
public bool confirmToDelivery(int id) { int idDel = (from c in _entities.delivery where c.orderdelivery_id == id select c.delivery_id).FirstOrDefault(); try { delivery delivery = _entities.delivery.Find(idDel); delivery.delivery_status = "отправлен"; _entities.Entry(delivery).State = EntityState.Modified; _entities.SaveChanges(); } catch { return(false); } return(true); }
public ActionResult Create([Bind(Include = "id,adresse,date,frais,poids,state,deliver_men_id")] delivery delivery, int?idDeliveryMen) { httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var postTask = httpClient.PostAsJsonAsync <delivery>(baseAddress + "ConsomiTounsi/Delivery/newDelivery?id=" + delivery.deliver_men_id, delivery); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } return(View(new delivery())); }
protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = GridView1.Rows[e.RowIndex]; int deliveryId = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]); string status = (row.FindControl("txtDeliveryStatus") as TextBox).Text; using (Team2_BookDBEntities entities = new Team2_BookDBEntities()) { delivery delivery = (from d in entities.deliveries where d.deliveryID == deliveryId select d).FirstOrDefault(); delivery.deliveryStatus = status; entities.SaveChanges(); } GridView1.EditIndex = -1; this.BindGrid(); }
private void addDelivery() { int salesId = (from s in dc.salesOrders select s.salesId).Max(); delivery del = new delivery(); del.description = ""; del.deliveryAddress = TextBox2.Text + ", " + TextBox3.Text + ", " + TextBox4.Text + " " + TextBox1.Text + " " + ddlState.Text; del.deliveryStatus = "pending"; del.salesId = salesId; dc.deliveries.InsertOnSubmit(del); try { dc.SubmitChanges(); } catch (Exception ex) { Console.WriteLine(ex); } }
protected void Button5_Click(object sender, EventArgs e) { int id = int.Parse(Session["cust"].ToString()); shoppingDataContext sdc = new shoppingDataContext(); int qty = int.Parse(Request.QueryString["qnty"]); int pid = int.Parse(Request.QueryString["pro-id"]); int oid = int.Parse(ViewState["o-id"].ToString()); delivery del = new delivery() { cust_id = id, order_id = oid, delivery_date = DateTime.Now.AddDays(3), delivery_status = "Successfully placed.." }; sdc.deliveries.InsertOnSubmit(del); sdc.SubmitChanges(); var qu = from p in sdc.products where p.id == pid select p; foreach (var q in qu) { ViewState["q"] = q.prod_quantity; } int newqnty = int.Parse(ViewState["q"].ToString()) - qty; var query4 = from c in sdc.products where c.id == pid select c; foreach (var q in query4) { q.prod_quantity = newqnty; } sdc.SubmitChanges(); Response.Redirect("/customer/cust_delivery.aspx?pro-id=" + pid + "&order-id=" + oid); }
private void addDelivery() { int salesId = (from s in dc.salesOrders select s.salesId).Max(); delivery del = new delivery(); del.description = ""; del.deliveryAddress = results["address_street"] + ", " + results["address_zip"] + " " + results["address_city"] + " " + results["address_state"]; del.deliveryAddress = del.deliveryAddress.Replace('+', ' '); del.deliveryAddress = del.deliveryAddress.Replace("%2C", ","); del.deliveryStatus = "pending"; del.salesId = salesId; dc.deliveries.InsertOnSubmit(del); try { dc.SubmitChanges(); } catch (Exception ex) { Console.WriteLine(ex); } }
protected void btnSubmit_Click(object sender, EventArgs e) { string schedule = Calendar1.SelectedDate.ToShortDateString() + " " + ddlTime.SelectedValue.ToString(); DateTime thedate = DateTime.Parse(schedule); try { if (getT(thedate) == true) { String didd = (string)(Session["name"]); string diddd = convertStrToId(didd); int did = Int32.Parse(diddd); String driver = ddlDriver.Text; String fakeDriver = Membership.GetUser(driver).ProviderUserKey.ToString(); Guid realDriver = Guid.Parse(fakeDriver); deliverySchedule ds = new deliverySchedule { deliveryDate = thedate, driverId = realDriver, deliveryId = did }; db.deliverySchedules.InsertOnSubmit(ds); db.SubmitChanges(); delivery del = (from d in db.deliveries where d.deliveryId == did select d).Single(); del.deliveryStatus = "completed"; db.SubmitChanges(); String dialog = "Delivery Successfully Added !"; Session["take2"] = dialog; Response.Redirect("DeliveryHome.aspx"); } } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Delivery Failure.')" + ex.Message, true); } }
public ActionResult Details(int id = 0) { delivery delivery = db.delivery.Find(id); return(View(delivery)); }
partial void Deletedelivery(delivery instance);
partial void Updatedelivery(delivery instance) { instance.timeStampLastUpdate = DateTime.Now; this.ExecuteDynamicUpdate(instance); }
private static Boolean ProcessBatches(delivery deliveryDocument, List <batch> batches) { DALPortalDataContext dc = new DALPortalDataContext(); Boolean returnValue = true; // Remove all batches attached to this document BatchClass.RemoveBatchesDocument(deliveryDocument.docId, deliveryDocument.docType, dc); foreach (batch batchLine in batches) { try { batch batch = BatchClass.GetBatch(batchLine.batchNumber, batchLine.heatNumber, batchLine.itemId, deliveryDocument.companyCode, dc); Boolean newBatch = false; if (batch == null) { batch = new batch(); newBatch = true; } if (newBatch) { batch.batchNumber = batchLine.batchNumber; batch.companyCode = deliveryDocument.companyCode; } batch.itemId = batchLine.itemId; batch.certificateIndexNumber = batchLine.certificateIndexNumber; batch.heatNumber = batchLine.heatNumber; batch.ixosArchiveId = batchLine.ixosArchiveId; if (newBatch) { // Check if certificate is already on the server String fileName = "CERT_" + batchLine.ixosArchiveId + ".pdf"; String filePath = Path.Combine(Parameters_DataProcessor.CompanyFilesRoot, "Certificates", fileName); String dbPath = Path.Combine(@"~\Files\Certificates", fileName); if (File.Exists(filePath)) { batch.certificateLink = dbPath; } } foreach (batchDocument batchDocLine in batchLine.batchDocuments) { // Check if Batch relates to document batchDocument batchDoc = batch.batchDocuments.Where(c => c.baseDocId.Equals(deliveryDocument.docId) && c.baseLineNum.Equals(batchDocLine.baseLineNum) && c.baseDocType.Equals("DL")).FirstOrDefault(); Boolean newBatchDoc = false; if (batchDoc == null) { newBatchDoc = true; batchDoc = new batchDocument(); batchDoc.baseDocId = deliveryDocument.docId; batchDoc.baseLineNum = batchDocLine.baseLineNum; batchDoc.baseDocType = "DL"; } batchDoc.quantity = batchDocLine.quantity; if (newBatchDoc) { batch.batchDocuments.Add(batchDoc); } } if (newBatch) { dc.batches.InsertOnSubmit(batch); } dc.SubmitChanges(); } catch (Exception ex) { Trace.WriteLine(String.Format("Error Processing Batches for Delivery {0} for company {1}. Error: {2}", deliveryDocument.documentNumber, deliveryDocument.companyCode, ex.Message), "ProcessBatches"); returnValue = false; } } return(returnValue); }
public static Boolean ProcessDelivery(String fileContent, out delivery deliveryDocument) { deliveryDocument = new delivery(); List <batch> batches = new List <batch>(); String sapECC6DocNum = String.Empty; DALPortalDataContext dc = new DALPortalDataContext(); Boolean update; Boolean returnValue = true; try { List <String> items = new List <String>(); XDocument xmldoc = XDocument.Parse(fileContent); XElement docTypeElement = xmldoc.Element("DELVRY03"); XElement iDocElement = docTypeElement.Element("IDOC"); XElement deliveryElement = iDocElement.Element("E1EDL20"); // Company String sectionCode = deliveryElement.Element("VKORG").Value; String companyCode = CompanyClass.GetCompanyBasedOnSection(sectionCode, dc); sapECC6DocNum = RemoveLeadingZeros(deliveryElement.Element("VBELN").Value); // Check if Sales Order already exists deliveryDocument = dc.deliveries.Where(c => c.documentNumber.Equals(sapECC6DocNum) && c.companyCode.Equals(companyCode)).FirstOrDefault(); if (deliveryDocument == null) { deliveryDocument = new delivery(); deliveryDocument.companyCode = companyCode; deliveryDocument.documentNumber = sapECC6DocNum; deliveryDocument.docStatusCode = "O"; update = false; } else { update = true; } // Document Header info String sapECC6BusinessPartnerCode = RemoveLeadingZeros(deliveryElement.Elements("E1ADRM1").Where(c => c.Element("PARTNER_Q").Value.Equals("AG")).FirstOrDefault().Element("PARTNER_ID").Value); businessPartner bp = Objects.BusinessPartnerClass.GetBusinessPartner(sapECC6BusinessPartnerCode, deliveryDocument.companyCode, dc); if (bp == null) { throw new Exception(String.Format("BusinessPartner {0} does not exists.", sapECC6BusinessPartnerCode)); } // Get BusinessPartnerID deliveryDocument.businessPartnerId = bp.businessPartnerId; // Dates XElement delDateElement = deliveryElement.Elements("E1EDT13").ToList().Where(c => c.Element("QUALF").Value.Equals("007")).FirstOrDefault(); deliveryDocument.deliveryDate = DateTime.ParseExact(delDateElement.Element("NTEND").Value, "yyyyMMdd", CultureInfo.CurrentCulture); XElement del2DateElement = deliveryElement.Elements("E1EDT13").ToList().Where(c => c.Element("QUALF").Value.Equals("015")).FirstOrDefault(); deliveryDocument.docDate = DateTime.ParseExact(del2DateElement.Element("NTEND").Value, "yyyyMMdd", CultureInfo.CurrentCulture); deliveryDocument.createDate = DateTime.ParseExact(del2DateElement.Element("NTEND").Value, "yyyyMMdd", CultureInfo.CurrentCulture); if (deliveryDocument.deliveryDate < DateTime.Now.AddYears(-50)) { deliveryDocument.deliveryDate = deliveryDocument.docDate; } //// Delivery lines List <XElement> deliveryLines = deliveryElement.Elements("E1EDL24").Where(c => c.Element("HIPOS") == null).ToList(); List <XElement> deliverySubLines = deliveryElement.Elements("E1EDL24").Where(c => c.Element("HIPOS") != null).ToList(); foreach (var deliveryLineElement in deliveryLines) { deliveryLine line = new deliveryLine(); String lineNumString = deliveryLineElement.Element("POSNR").Value; Int32 lineNum = Convert.ToInt32(lineNumString); Boolean newLine = false; if (update && deliveryDocument.deliveryLines.Any(c => c.lineNum.Equals(lineNum))) { line = deliveryDocument.deliveryLines.Where(c => c.lineNum.Equals(lineNum)).FirstOrDefault(); } else { line.lineNum = lineNum; newLine = true; } // DeliveryLine is not connected to a Sales Order if (deliveryLineElement.Element("VGBEL") == null) { continue; } String sapSODocNum = RemoveLeadingZeros(deliveryLineElement.Element("VGBEL").Value); Int32 sapSOLineNum = Convert.ToInt32(deliveryLineElement.Element("VGPOS").Value); salesOrderLine salesOrderLine = Objects.SalesOrderClass.GetSalesOrderLine(sapSODocNum, lineNum, companyCode, dc); if (salesOrderLine == null) { Trace.WriteLine(String.Format("Cannot find Sales Order {0}, Line {1} for Delivery {2}.", sapSODocNum, sapSOLineNum, sapECC6DocNum), "MapDeliveryXMLToSBO"); returnValue = false; continue; } String itemCode = RemoveLeadingZeros(deliveryLineElement.Element("MATNR").Value); item item = Objects.ItemClass.GetItem(itemCode, companyCode, dc); // Get POSTYPE String posType = deliveryLineElement.Element("E1EDL26").Element("PSTYV").Value; XElement baseLineNum = deliveryLineElement.Element("HIPOS"); // Add Batchinfo Decimal quantity = Convert.ToDecimal(deliveryLineElement.Element("LFIMG").Value, NumberFormatInfo.InvariantInfo); if (lineNumString.Substring(0, 1).Equals("9")) { continue; } if (Serac.BasicFunctions.Right(itemCode, 1).Equals("B") && (posType == "ZBNI" || posType == "ZCNI")) { // Get Quantity and Batches from Treatment line GetBatchesTreatmentLine(ref batches, ref quantity, line.lineNum, deliverySubLines, item.itemId); } else if (quantity > 0) { GetBatch(ref batches, line.lineNum, deliveryLineElement, quantity, item.itemId); } else { // Get Quantity and Batches from "Charge Splitsing" GetBatchesChargeSplitsing(ref batches, ref quantity, line.lineNum, deliverySubLines, item.itemId); } // Update Currency from base document if (deliveryDocument.currencyCode == null) { deliveryDocument.currencyCode = salesOrderLine.salesOrder.currencyCode; deliveryDocument.currencyRate = salesOrderLine.salesOrder.currencyRate; } line.baseDocId = salesOrderLine.salesOrder.docId; line.baseLineNum = Convert.ToInt32(deliveryLineElement.Element("VGPOS").Value); line.baseDocType = "SO"; line.quantity = quantity; line.itemId = item.itemId; line.lineStatusCode = "O"; line.itemDescription = salesOrderLine.itemDescription; // Get Certificates as ordered from base document line.certOrdered = salesOrderLine.certOrdered; // Add Line to SBO delivery line if (newLine) { deliveryDocument.deliveryLines.Add(line); } } } catch (Exception ex) { Trace.WriteLine(String.Format("Error Converting Delivery XML to WebPortal format. Error: {0}", ex.Message), "ProcessDelivery"); return(false); } if (deliveryDocument.deliveryLines.Count == 0) { return(false); } if (update) { try { dc.SubmitChanges(); Trace.WriteLine(String.Format("Updating Delivery {0} for company {1} Successfull.", deliveryDocument.documentNumber, deliveryDocument.companyCode), "ProcessDelivery"); } catch (Exception ex) { Trace.WriteLine(String.Format("Error Updating Delivery {0} for company {1}. Error: {2}", deliveryDocument.documentNumber, deliveryDocument.companyCode, ex.Message), "ProcessDelivery"); return(false); } } else { try { dc.deliveries.InsertOnSubmit(deliveryDocument); dc.SubmitChanges(); Trace.WriteLine(String.Format("Creating Delivery {0} for company {1} Successfull.", deliveryDocument.documentNumber, deliveryDocument.companyCode), "ProcessDelivery"); } catch (Exception ex) { Trace.WriteLine(String.Format("Error Creating Delivery {0} for company {1}. Error: {2}", deliveryDocument.documentNumber, deliveryDocument.companyCode, ex.Message), "ProcessDelivery"); return(false); } } if (!ProcessBatches(deliveryDocument, batches)) { return(false); } return(returnValue); }
partial void Updatedelivery(delivery instance);
public Boolean ProcessDataFromXML(String databaseName, String fileContent) { Boolean returnValue = true; try { // Check xml type // SAPECC6 if (fileContent.Contains("IDOC")) { businessPartner customer = new businessPartner(); DALPortalDataContext dc = new DALPortalDataContext(); String companyCode; //Customer if (fileContent.Contains("DEBMAS03")) { if (!XMLSAPECC6Processor.ProcessCustomer(fileContent, out customer, out companyCode)) { return(false); } CreateUsers(customer, companyCode, dc); } //SalesOrder if (fileContent.Contains("ORDERS05")) { salesOrder document = new salesOrder(); if (!XMLSAPECC6Processor.ProcessSalesOrder(fileContent, out document)) { return(false); } } //Delivery if (fileContent.Contains("DELVRY03")) { delivery document = new delivery(); if (!XMLSAPECC6Processor.ProcessDelivery(fileContent, out document)) { return(false); } } //Item if (fileContent.Contains("MATMAS05")) { if (!XMLSAPECC6Processor.ProcessItem(fileContent)) { return(false); } } } } catch (Exception ex) { Trace.WriteLine(String.Format("Process XML file Failed. Error: {0}", ex.Message), "ProcessDataFromXML"); return(false); } return(returnValue); }
partial void Insertdelivery(delivery instance);