コード例 #1
0
        public ActionResult Save(BulkOrder obj)
        {
            // Always save the Bulk Order then maybe re-direct to SendEmail
            string btn = Request.Form["btnSave"];
            int pk = ReplenishmentsService.fnSaveBulkOrder(obj);

            if (btn == "Send Email")
            {
                return RedirectToAction("Email", obj);
            }

            TempData["SaveResult"] = "Order Saved at " + DateTime.Now.ToString();

            return RedirectToAction("Edit", new { id = pk });
        }
コード例 #2
0
 public ActionResult Email(BulkOrder obj)
 {
     var EmailModel = ReplenishmentsService.fnCreateEmail(obj);
     return View("Email", EmailModel);
 }
コード例 #3
0
 public ActionResult Edit(int id)
 {
     BulkOrder vm = new BulkOrder();
     vm = ReplenishmentsService.fnFillBulkOrderFromDB(id);
     return View("~/Views/Replenishments/Edit.cshtml", vm);
 }
コード例 #4
0
        public static int fnSaveBulkOrder(BulkOrder obj)
        {
            System.Threading.Thread.Sleep(1500);
            using (var db = new MvcPhoenix.EF.CMCSQL03Entities())
            {
                if (obj.bulkorderid == -1)
                {
                    obj.bulkorderid = fnNewBulkOrderID();
                }

                var dbrow = db.tblBulkOrder.Find(obj.bulkorderid);
                dbrow.ClientID = obj.clientid;
                dbrow.OrderDate = obj.orderdate;
                dbrow.Comment = obj.ordercomment;
                dbrow.SupplyID = obj.supplyid;
                dbrow.BulkSupplierEmail = obj.bulksupplieremail;
                dbrow.EmailSent = obj.emailsent;
                db.SaveChanges();

                return obj.bulkorderid;
            }
        }
コード例 #5
0
        public static BulkOrder fnFillBulkOrderFromDB(int id)
        {
            using (var db = new MvcPhoenix.EF.CMCSQL03Entities())
            {
                BulkOrder obj = new BulkOrder();
                obj = (from t in db.tblBulkOrder
                       join c in db.tblClient on t.ClientID equals c.ClientID
                       where t.BulkOrderID == id
                       select new BulkOrder
                       {
                           bulkorderid = t.BulkOrderID,
                           clientid = t.ClientID,
                           clientname = c.ClientName,
                           logofilename = c.LogoFileName,
                           orderdate = t.OrderDate,
                           ordercomment = t.Comment,
                           supplyid = t.SupplyID,

                           bulksupplieremail = t.BulkSupplierEmail,
                           emailsent = t.EmailSent,
                       }).FirstOrDefault();

                obj.ListOfSupplyIDs = fnListOfSupplyIDs(obj.clientid);

                obj.ListOfBulkOrderItem = (from oi in db.tblBulkOrderItem
                                           join pm in db.tblProductMaster on oi.ProductMasterID equals pm.ProductMasterID
                                           where oi.BulkOrderID == id
                                           select new BulkOrderItem
                                           {
                                               bulkorderitemid = oi.BulkOrderItemID,
                                               bulkorderid = oi.BulkOrderID,
                                               productmasterid = oi.ProductMasterID,
                                               mastercode = pm.MasterCode,
                                               mastername = pm.MasterName,
                                               weight = oi.Weight,
                                               itemstatus = oi.Status,
                                               eta = oi.ETA,
                                               datereceived = oi.DateReceived,
                                               itemnotes = oi.ItemNotes
                                           }).ToList();

                return obj;
            }
        }
コード例 #6
0
        public static BulkOrderEmailViewModel fnCreateEmail(BulkOrder vm)
        {
            BulkOrderEmailViewModel message = new BulkOrderEmailViewModel();

            message.bulkorderid = vm.bulkorderid;
            message.clientname = vm.clientname;
            message.logofilename = vm.logofilename;
            message.ToAddress = vm.bulksupplieremail;
            message.FromAddress = HttpContext.Current.User.Identity.Name;
            message.Subject = "CMC Replenishment Order: " + vm.bulkorderid;

            var q = fnFillBulkOrderFromDB(vm.bulkorderid);
            System.Text.StringBuilder s = new System.Text.StringBuilder();
            s.Append("<div class='table-responsive'><table class='table table-hover table-striped'><thead><tr><th>Mastercode</th><th>Master Name</th><th align='right'>Weight</th></tr></thead>");

            foreach (var item in q.ListOfBulkOrderItem)
            {
                s.Append(String.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>", item.mastercode, item.mastername, item.weight));
            }

            s.Append("</table></div>");

            message.MessageBody = s.ToString();

            return message;
        }