public ActionResult DeleteConfirmed(int id) { ModelOrder modelOrder = db.Order.Find(id); db.Order.Remove(modelOrder); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Code,UserId,CreateDate,ExportDate,DeliveryAddress,DeliveryName,DeliveryPhone,DeliveryEmail,Update_At,Update_By,Status")] ModelOrder modelOrder) { if (ModelState.IsValid) { db.Entry(modelOrder).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(modelOrder)); }
public ActionResult Order() { ModelOrder modelorder = new ModelOrder() { OrganismList = _context.Organism.ToList(), ImplementList = _context.ImplementType.ToList(), SgrnaList = _context.Sgrna.ToList(), OfftargetList = _context.OffTarget.ToList() }; return(View(modelorder)); }
public ModelOrder Order([FromUri] string orderNumber) { var item = DB.MyOrder.AsNoTracking().Where(x => x.ORDER_NUMBER == orderNumber).FirstOrDefault(); if (item == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } ModelOrder model = new ModelOrder(item); return(model); }
// GET: Admin/Orders/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ModelOrder modelOrder = db.Order.Find(id); if (modelOrder == null) { return(HttpNotFound()); } return(View(modelOrder)); }
private static void SendReceivedPending() { ITransactionService _transactionService = new TransactionService(); try { string dpPath = UserSession.DB_PATH; var db = new SQLiteConnection(dpPath); var data = db.Table <ReceivedOrderTable>(); //Call Table int TotalCount = data.Count(); var TotalSendCount = 0; foreach (var d in data) { ModelOrder modelOrder = new ModelOrder { Agent = d.Agent, AgentStr = d.AgentStr, OrderNumber = d.OrderNumber, PackageQty = d.PackageQty, ReceivedTS = d.ReceivedTS, Status = d.Status }; ReceivePackageModel model = new ReceivePackageModel { ModelOrder = modelOrder, UpdateTS = false }; var result = _transactionService.ReceivePackage(model); if (result) { db.Delete(d); TotalSendCount++; } } } catch (Exception ex) { } }
public async void TestApiPostCart() { ModelOrder model = new ModelOrder(); model.CustomerId = 1; model.Token = token; var jsonResult = await controller.Post(model); Assert.NotNull(jsonResult); Assert.True(jsonResult.Success); var result = await controller.Get(token); Assert.NotNull(result); Assert.Equal(0, result.Count); }
public IHttpActionResult GetDatHangs([FromBody] ModelOrder order) { // taiKhoan = "*****@*****.**" // pass = "******" ////JObject json = JObject.Parse(order.products); //JArray ps = (JArray)json.GetValue("products"); //int total = (int)json.GetValue("total");] List <InforOrder> listOrder = order.products; int tong = order.total; var exProc = db.Database.SqlQuery <int>("exec DonHang_Insert @idStore, @idUser, @ThoiGian, @DiaChi, @TongTien", new SqlParameter("idStore", order.idStore), new SqlParameter("idUser", order.idUser), new SqlParameter("ThoiGian", DateTime.Now), new SqlParameter("DiaChi", order.address), new SqlParameter("TongTien", tong) ) .ToArray(); //IEnumerable<string> result = res; int idDonHang = exProc[0]; foreach (InforOrder item in listOrder) { ModelProducts model = new ModelProducts(); model.id = item.id; model.count = item.count; db.Database.ExecuteSqlCommand("exec DatHang_Insert @iddonhang, @idMonAn, @count", new SqlParameter("iddonhang", idDonHang), new SqlParameter("idMonAn", model.id), new SqlParameter("count", model.count)); } JObject res = new JObject(); res["status"] = 0; return(Ok(res.ToString())); }
void ProcessDeliver(string deliveredTo) { foreach (var item in tableItems) { ModelOrder modelOrder = new ModelOrder { OrderNumber = item.Heading, PackageQty = item.PackageQty, DeliveredTS = DateTime.UtcNow, Status = (int)StatusTypeEnums.DELIVERED, DeliveredTo = deliveredTo, GUID = item.GUID }; DeliverPackageModel model = new DeliverPackageModel { ModelOrder = modelOrder, UpdateTS = true }; if (GetConnectionStatus()) { var result = _transactionService.DeliverPackage(model); if (!result) { AddToDeliverTable(model); continue; } } else { // save to local db AddToDeliverTable(model); } } }
public async Task <ModelApiResponse> Post([FromBody] ModelOrder param) { ModelApiResponse modelApiResponse = new ModelApiResponse(); try { if (param != null) { using (var context = new ApplicationDbContext()) { var newItem = new BondoraOrder(); newItem.CustomerId = param.CustomerId; newItem.DateOrder = DateTime.Now; newItem.Token = param.Token; context.Entry(newItem).State = EntityState.Added; await context.SaveChangesAsync(); modelApiResponse.Success = true; modelApiResponse.Message = ""; modelApiResponse.CountOrdered = 0; } } else { modelApiResponse.Success = false; modelApiResponse.Message = localizer["NoItemsToSubmit"].Value; modelApiResponse.CountOrdered = 0; } } catch (Exception ex) { modelApiResponse.Success = false; modelApiResponse.Message = ex.Message + "<br />" + ex.InnerException + "<br />" + ex.StackTrace; modelApiResponse.CountOrdered = 0; } return(modelApiResponse); }
void showCompleteDialog() { //Inflate layout View view = LayoutInflater.Inflate(Resource.Layout.ReceiveOKDialog, null); AlertDialog builder = new AlertDialog.Builder(this).Create(); builder.SetView(view); builder.SetCanceledOnTouchOutside(false); Button buttonYesAction = view.FindViewById <Button>(Resource.Id.btnYes); Button buttonNoAction = view.FindViewById <Button>(Resource.Id.btnNo); buttonYesAction.Click += delegate { try { //send packages foreach (var item in tableItems) { ModelOrder modelOrder = new ModelOrder { Agent = SELECTED_AGENT, AgentStr = SELECTED_AGENTSTR, OrderNumber = item.Heading, PackageQty = item.PackageQty, ReceivedTS = DateTime.UtcNow, Status = (int)StatusTypeEnums.RECEIVED }; ReceivePackageModel model = new ReceivePackageModel { ModelOrder = modelOrder, UpdateTS = false }; if (GetConnectionStatus()) { var result = _transactionService.ReceivePackage(model); if (!result) { // TBD: If api fails to process a package AddToLocalReceiveTable(model); continue; } } else { // save to local db AddToLocalReceiveTable(model); } } UserSession.SendingAllPendingTransactions(); // clear all info ClearScreen(); // Reset ListView InitializeListView(); // Display Dialog Android.Widget.Toast.MakeText(this, "Transaction Completed!", Android.Widget.ToastLength.Short).Show(); builder.Dismiss(); Finish(); } catch { Android.Widget.Toast.MakeText(this, "Error : Cannot Process Transaction!", Android.Widget.ToastLength.Short).Show(); } }; buttonNoAction.Click += delegate { builder.Dismiss(); }; builder.Show(); }
private void ProcessLoadContainer() { try { foreach (var item in tableItems) { // check if item exists in database and item has RECEIVED status // if yes : process // if no : skip // check connection if (GetConnectionStatus()) { try { // call api var tempModel = _transactionService.CheckPackageOrder(item.Heading); if (tempModel == null) { continue; } if (tempModel.Status != (int)StatusTypeEnums.RECEIVED) { continue; } } catch (Exception ex) { //Android.Widget.Toast.MakeText(this, "Error!", Android.Widget.ToastLength.Short).Show(); } } // PROCESS ORDER ModelOrder modelOrder = new ModelOrder { LotNo = SELECTED_LOTNO, LotNoStr = SELECTED_LOTNOSTR, OrderNumber = item.Heading, PackageQty = item.PackageQty, LoadedTS = DateTime.UtcNow, Status = (int)StatusTypeEnums.LOADED, GUID = item.GUID }; LoadContainerModel model = new LoadContainerModel { ModelOrder = modelOrder, UpdateTS = true }; if (GetConnectionStatus()) { // check if valid package var result = _transactionService.LoadContainer(model); if (!result) { AddToLocalLoadContainerTable(model); continue; } } else { // save to local db AddToLocalLoadContainerTable(model); } } } catch (Exception ex) { Toast.MakeText(this, ex.ToString(), ToastLength.Short).Show(); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.DeliveryPackage); Button cancelAction = FindViewById <Button>(Resource.Id.btnCancel); Button completeAction = FindViewById <Button>(Resource.Id.btnComplete); Button completeNextAction = FindViewById <Button>(Resource.Id.btnCompleNextDeliver); ImageButton barcodeAction = FindViewById <ImageButton>(Resource.Id.ImgBtnScan); EditText barcodeEditText = FindViewById <EditText>(Resource.Id.txtBarcode); barcodeEditText.KeyPress += (object sender, View.KeyEventArgs e) => { e.Handled = false; if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter) { //add your logic here AddNewPackage(); e.Handled = true; } }; // complete barcodeAction.Click += (object sender, EventArgs e) => { AddNewPackage(); }; // Cancel cancelAction.Click += (object sender, EventArgs e) => { Finish(); }; // complete completeAction.Click += (object sender, EventArgs e) => { EditText txtReceivedBy = FindViewById <EditText>(Resource.Id.txtReceivedBy); EditText packageQtyTxt = FindViewById <EditText>(Resource.Id.txtPackageQty); EditText barcodeTxt = FindViewById <EditText>(Resource.Id.txtBarcode); EditText deliveredDateTxt = FindViewById <EditText>(Resource.Id.txtDateDelivered); // Get barcode var barcodeValue = barcodeTxt.Text; if (String.IsNullOrEmpty(barcodeValue)) { Android.Widget.Toast.MakeText(this, "Empty Package Barcode!", Android.Widget.ToastLength.Short).Show(); return; } // Delivered To var deliveredTo = txtReceivedBy.Text; if (String.IsNullOrEmpty(deliveredTo)) { Android.Widget.Toast.MakeText(this, "Received By is Empty!", Android.Widget.ToastLength.Short).Show(); return; } // Package Count var packageQty = packageQtyTxt.Text; if (String.IsNullOrEmpty(packageQty)) { Android.Widget.Toast.MakeText(this, "Package Count is Empty!", Android.Widget.ToastLength.Short).Show(); return; } if (Convert.ToInt32(packageQty) < 0) { Android.Widget.Toast.MakeText(this, "Negative value is not allowed!", Android.Widget.ToastLength.Short).Show(); return; } var tempModel = _transactionService.CheckPackageOrder(barcodeValue); if (tempModel == null) { Android.Widget.Toast.MakeText(this, "Package does not exist!", Android.Widget.ToastLength.Short).Show(); return; } if (tempModel.Status != (int)StatusTypeEnums.UNLOADED) { Android.Widget.Toast.MakeText(this, "Invalid Package Status!", Android.Widget.ToastLength.Short).Show(); return; } var _tempDeliveredDate = deliveredDateTxt.Text; if (String.IsNullOrEmpty(_tempDeliveredDate)) { Android.Widget.Toast.MakeText(this, "Delivered Date is Empty!", Android.Widget.ToastLength.Short).Show(); return; } var DeliveredDate = Convert.ToDateTime(_tempDeliveredDate); ModelOrder modelOrder = new ModelOrder { OrderNumber = barcodeValue, PackageQty = Convert.ToInt32(packageQty), DeliveredTS = DateTime.UtcNow, Status = (int)StatusTypeEnums.DELIVERED, DeliveredTo = deliveredTo, GUID = tempModel.GUID, DeliveredDate = DeliveredDate }; DeliverPackageModel model = new DeliverPackageModel { ModelOrder = modelOrder, UpdateTS = true }; if (GetConnectionStatus()) { try { var result = _transactionService.DeliverPackage(model); // If Error if (!result) { Android.Widget.Toast.MakeText(this, "Error!", Android.Widget.ToastLength.Short).Show(); AddToDeliverTable(model); return; } UserSession.SendingAllPendingTransactions(); Android.Widget.Toast.MakeText(this, "Transaction Successful!", Android.Widget.ToastLength.Short).Show(); } catch (Exception ex) { Android.Widget.Toast.MakeText(this, "Error!", Android.Widget.ToastLength.Short).Show(); } } else { // save to local db AddToDeliverTable(model); } // go back to main menu Finish(); }; // complete and deliver next completeNextAction.Click += (object sender, EventArgs e) => { EditText barcodeTxt = FindViewById <EditText>(Resource.Id.txtBarcode); EditText packageQtyTxt = FindViewById <EditText>(Resource.Id.txtPackageQty); EditText txtReceivedBy = FindViewById <EditText>(Resource.Id.txtReceivedBy); // Get barcode var barcodeValue = barcodeTxt.Text; if (String.IsNullOrEmpty(barcodeValue)) { Android.Widget.Toast.MakeText(this, "Empty Package Barcode!", Android.Widget.ToastLength.Short).Show(); return; } // Delivered To var deliveredTo = txtReceivedBy.Text; if (String.IsNullOrEmpty(deliveredTo)) { Android.Widget.Toast.MakeText(this, "Received By is Empty!", Android.Widget.ToastLength.Short).Show(); return; } // Package Count var packageQty = packageQtyTxt.Text; if (String.IsNullOrEmpty(packageQty)) { Android.Widget.Toast.MakeText(this, "Package Count is Empty!", Android.Widget.ToastLength.Short).Show(); return; } if (Convert.ToInt32(packageQty) < 0) { Android.Widget.Toast.MakeText(this, "Negative value is not allowed!", Android.Widget.ToastLength.Short).Show(); return; } var tempModel = _transactionService.CheckPackageOrder(barcodeValue); if (tempModel == null) { Android.Widget.Toast.MakeText(this, "Package does not exist!", Android.Widget.ToastLength.Short).Show(); return; } if (tempModel.Status != (int)StatusTypeEnums.UNLOADED) { Android.Widget.Toast.MakeText(this, "Invalid Package Status!", Android.Widget.ToastLength.Short).Show(); return; } ModelOrder modelOrder = new ModelOrder { OrderNumber = barcodeValue, PackageQty = Convert.ToInt32(packageQty), DeliveredTS = DateTime.UtcNow, Status = (int)StatusTypeEnums.DELIVERED, DeliveredTo = deliveredTo, GUID = tempModel.GUID }; DeliverPackageModel model = new DeliverPackageModel { ModelOrder = modelOrder, UpdateTS = true }; if (GetConnectionStatus()) { try { var result = _transactionService.DeliverPackage(model); // If Error if (!result) { Android.Widget.Toast.MakeText(this, "Error!", Android.Widget.ToastLength.Short).Show(); AddToDeliverTable(model); return; } UserSession.SendingAllPendingTransactions(); Android.Widget.Toast.MakeText(this, "Transaction Successful!", Android.Widget.ToastLength.Short).Show(); } catch (Exception ex) { Android.Widget.Toast.MakeText(this, "Error!", Android.Widget.ToastLength.Short).Show(); } } else { // save to local db AddToDeliverTable(model); } // clear text barcodeTxt.Text = String.Empty; packageQtyTxt.Text = "0"; txtReceivedBy.Text = String.Empty; }; }
private static void SendUnLoadContainerPending() { ITransactionService _transactionService = new TransactionService(); try { string dpPath = UserSession.DB_PATH; var db = new SQLiteConnection(dpPath); var data = db.Table <UnLoadContainerTable>(); //Call Table int TotalCount = data.Count(); var TotalSendCount = 0; var InvalidPackageCount = 0; foreach (var d in data) { ModelOrder modelOrder = new ModelOrder { GUID = d.GUID, LotNo = d.LotNo, LotNoStr = d.LotNoStr, OrderNumber = d.OrderNumber, PackageQty = d.PackageQty, UnloadedTS = d.LoadedTS, Status = d.Status, }; UnloadContainerModel model = new UnloadContainerModel { ModelOrder = modelOrder, UpdateTS = true }; // check if item exists in database and item has RECEIVED status // if yes : process // if no : delete from local table // check connection try { // call api var tempModel = _transactionService.CheckPackageOrder(model.ModelOrder.OrderNumber); if (tempModel == null) { InvalidPackageCount++; db.Delete(d); continue; } } catch (Exception ex) { //Android.Widget.Toast.MakeText(this, "Error!", Android.Widget.ToastLength.Short).Show(); } var result = _transactionService.UnloadContainer(model); if (result) { db.Delete(d); TotalSendCount++; } } } catch (Exception ex) { } }
private void SendDeliverPending() { try { string dpPath = UserSession.DB_PATH; var db = new SQLiteConnection(dpPath); var data = db.Table <DeliverTable>(); //Call Table int TotalCount = data.Count(); var TotalSendCount = 0; var InvalidPackageCount = 0; foreach (var d in data) { ModelOrder modelOrder = new ModelOrder { GUID = d.GUID, OrderNumber = d.OrderNumber, PackageQty = d.PackageQty, DeliveredTo = d.DeliveredTo, DeliveredTS = d.DeliveredTS, Status = d.Status, DeliveredDate = d.DeliveredDate }; DeliverPackageModel model = new DeliverPackageModel { ModelOrder = modelOrder, UpdateTS = true }; if (GetConnectionStatus()) { // check if item exists in database and item has RECEIVED status // if yes : process // if no : delete from local table // check connection try { // call api var tempModel = _transactionService.CheckPackageOrder(model.ModelOrder.OrderNumber); if (tempModel == null) { InvalidPackageCount++; db.Delete(d); continue; } } catch (Exception ex) { //Android.Widget.Toast.MakeText(this, "Error!", Android.Widget.ToastLength.Short).Show(); } var result = _transactionService.DeliverPackage(model); if (result) { db.Delete(d); TotalSendCount++; } } } DeliverCount(); if (TotalSendCount == 0 && InvalidPackageCount == 0) { Android.Widget.Toast.MakeText(this, "No Packages were sent!", Android.Widget.ToastLength.Short).Show(); return; } if (InvalidPackageCount > 0) { Android.Widget.Toast.MakeText(this, string.Format("{0} Invalid Package(s)!", InvalidPackageCount), Android.Widget.ToastLength.Short).Show(); return; } if (TotalCount == TotalSendCount) { Android.Widget.Toast.MakeText(this, "Successful sending of all packages!", Android.Widget.ToastLength.Short).Show(); } else if (TotalSendCount > 0) { Android.Widget.Toast.MakeText(this, "Only " + TotalSendCount + " Package(s) were Successfully Sent!", Android.Widget.ToastLength.Short).Show(); } } catch (Exception ex) { Android.Widget.Toast.MakeText(this, "Error !", Android.Widget.ToastLength.Short).Show(); // throw; } }
private void SendReceivedPending() { try { string dpPath = UserSession.DB_PATH; var db = new SQLiteConnection(dpPath); var data = db.Table <ReceivedOrderTable>(); //Call Table int TotalCount = data.Count(); var TotalSendCount = 0; foreach (var d in data) { ModelOrder modelOrder = new ModelOrder { Agent = d.Agent, AgentStr = d.AgentStr, OrderNumber = d.OrderNumber, PackageQty = d.PackageQty, ReceivedTS = d.ReceivedTS, Status = d.Status }; ReceivePackageModel model = new ReceivePackageModel { ModelOrder = modelOrder, UpdateTS = false }; if (GetConnectionStatus()) { var result = _transactionService.ReceivePackage(model); if (result) { db.Delete(d); TotalSendCount++; } } } // Update Count for LOAD Container ReceivedCount(); if (TotalSendCount == 0) { Android.Widget.Toast.MakeText(this, "No Packages were sent!", Android.Widget.ToastLength.Short).Show(); return; } if (TotalCount == TotalSendCount) { Android.Widget.Toast.MakeText(this, "Successful sending of all packages!", Android.Widget.ToastLength.Short).Show(); } else { Android.Widget.Toast.MakeText(this, "Only " + TotalSendCount + " Package(s) were Successfully Sent!", Android.Widget.ToastLength.Short).Show(); } } catch (Exception ex) { Android.Widget.Toast.MakeText(this, "Error !", Android.Widget.ToastLength.Short).Show(); // throw; } }