public ActionResult EditPackageGold(string PackageID, string Price, string Duration, string OrderDetailID) { b2bMemberPaid mem = new b2bMemberPaid(); b2bOrder order = new b2bOrder(); b2bOrderDetail orderDe = new b2bOrderDetail(); var svOrder = new OrderService(); var svMember = new MemberService(); try { #region Set b2bMemberPaid var countMem = svMember.SelectData <b2bMemberPaid>("*", " CreatedDate = GetDate() AND RowFlag > 0"); int CountMem = countMem.Count + 1; mem.MemberPaidCode = AutoGenCode("MPC", CountMem); mem.CompID = LogonCompID; mem.PaymentStatus = "B"; mem.IsShow = true; mem.IsDelete = false; #endregion #region Insert b2bMemberPaid svMember.InsertMemberPaid(mem); #endregion #region Set b2bOrder order.CompID = LogonCompID; order.MemberPaidID = mem.MemberPaidID; order.OrderStatus = "B"; order.TotalPrice = decimal.Parse(Price); order.IsShow = true; order.IsDelete = false; order.RowFlag = 1; order.IsInactive = false; order.IsSend = false; #endregion var OrderDetails = new List <b2bOrderDetail>(); #region Set Model Order Detail var countOrder = svMember.SelectData <b2bOrderDetail>("*", " CreatedDate = GetDate() AND RowFlag > 0"); int CountOrder = countOrder.Count + 1; List <int> PackagesId = new List <int>(); foreach (string ID in PackageID.Split(',')) { if (!string.IsNullOrEmpty(ID)) { int intID; bool isNum = int.TryParse(ID, out intID); if (isNum) { PackagesId.Add(intID); } } } for (var i = 0; i < PackagesId.Count(); i++) { var GetPackage = svMember.SelectData <b2bPackage>("*", "PackageID = " + PackagesId[i]).First(); var GetOrderDetail = svMember.SelectData <b2bOrderDetail>("*", "IsDelete = 0 AND PackageID = " + PackagesId[i]).First(); var detail = new b2bOrderDetail(); detail.OrderType = 2; detail.PackageID = PackagesId[i]; detail.RowFlag = 1; detail.IsDelete = false; detail.IsInactive = false; detail.OrderDetailCode = AutoGenCode("ORT", CountOrder); detail.PackagePrice = decimal.Parse(Price); detail.OrderCount = (byte)(DataManager.ConvertToInteger(GetOrderDetail.OrderCount) + 1); detail.OptionValue = GetPackage.OptionValue; detail.OptionValueUnit = GetPackage.OptionValueUnit; detail.Duration = DataManager.ConvertToInteger(Duration); CountOrder++; OrderDetails.Add(detail); } #endregion #region Insert b2bOrder svOrder.InsertOrder(order, OrderDetails); #endregion if (svOrder.IsResult) { UpdateInactive(OrderDetailID); SendEmailOrderPackage(Price); } } catch (Exception ex) { return(Json(new { IsSuccess = false })); } return(Json(new { IsSuccess = true })); }
public ActionResult Summary(List <int> PackageID, List <int> Qty, List <bool> Package) { #region Using Service var svPaymentAcc = new PaymentAccountService(); var svCompany = new CompanyService(); var svPackage = new PackageService(); var svOrder = new OrderService(); #endregion #region Set Variable var model = new b2bOrder(); var OrderDetails = new List <b2bOrderDetail>(); var OrderNumber = 1; decimal OrderTotalPrice = 0; #endregion #region Set Model Order Detail for (var i = 0; i < Package.Count(); i++) { if (Package[i] == true) { var GetPackage = svPackage.SelectData <b2bPackage>(" PackageID,Price ", " PackageID = " + PackageID[i]).First(); #region วน Add Package เข้า List Order Detail ตามจำนวน ที่สั่งซื้อ for (var x = 1; x <= Qty[i]; x++) { var detail = new b2bOrderDetail(); detail.OrderType = 1; detail.PackageID = PackageID[i]; detail.RowFlag = 1; detail.IsDelete = true; detail.OrderDetailCode = AutoGenCode(CreateOrderDetialCode((int)PackageID[i]), OrderNumber); OrderNumber++; OrderDetails.Add(detail); } #endregion OrderTotalPrice += ((decimal)GetPackage.Price * Qty[i]); } } #endregion #region Set Model Order model.CompID = LogonCompID; model.OrderStatus = "C"; model.RowFlag = 1; model.IsDelete = true; model.TotalPrice = OrderTotalPrice; #endregion #region InsertOrder svOrder.InsertOrder(model, OrderDetails); #endregion #region Set ViewBag ViewBag.OrderID = model.OrderID; var Company = svCompany.SelectData <view_Company>(" * ", " CompID = " + LogonCompID).First(); ViewBag.Company = Company; //var PaymentAccounts = svPaymentAcc.SelectData<View_PaymentAccount>(" PaymentAccID, BankID, AccName, AccNo, BranchName, PaymentTypeID, BankName, LogoImgPath, PaymentTypeName", ""); //ViewBag.PaymentAccounts = PaymentAccounts; CommonService svCommon = new CommonService(); ViewBag.EnumServiceType = svCommon.SelectEnum(CommonService.EnumType.SearchByServiceType); #endregion ViewBag.EnumServiceType = svCommon.SelectEnum(CommonService.EnumType.SearchByServiceType); GetStatusUser(); return(View()); }