public bool BuySmsByCashAccount(int ChargeSetId, string pwd) { bool rs = false; var currentUser = AuthManager.GetCurrentUser(); var bm = this.businessmanRepository.FindAll(p => p.Code == currentUser.Code && p is Carrier).FirstOrDefault(); var mchargeset = this.smsChargeRepository.FindAll(p => p.ID == ChargeSetId).FirstOrDefault(); var payNo = bm.GetPayNo(); BuyDetail smsbuy = new BuyDetail { Count = mchargeset.Count, PayAmount = mchargeset.TotalPrice, PayWay = EnumPayMethod.Account, PayNo = payNo, BuyTime = DateTime.Now, Name = currentUser.OperatorName, PayFee = Math.Round(mchargeset.TotalPrice * SystemConsoSwitch.Rate, 2) }; //string outpaynum = payMentClientProxy.PaymentByCashAccount(currentUser.CashbagCode, currentUser.CashbagKey, payNo, "短信购买", mchargeset.TotalPrice, pwd); var reslut = payMentClientProxy.PaymentByCashAccount(currentUser.CashbagCode, currentUser.CashbagKey, payNo, "短信购买", mchargeset.TotalPrice, pwd); string outpaynum = reslut.Item2; if (!string.IsNullOrEmpty(outpaynum)) { bm.SMS.RemainCount += mchargeset.Count; smsbuy.BuyState = EnumPayStatus.OK; smsbuy.OutPayNo = outpaynum; rs = true; } smsbuy.PayTime = DateTime.Now; bm.BuyDetails.Add(smsbuy); this.unitOfWorkRepository.PersistUpdateOf(bm); this.unitOfWork.Commit(); return(rs); }
public BuyDetail GetBuyPropertyById(int id) { using (var db = new ApplicationDbContext()) { var entity = db.RealEstateBuy.Single(s => s.BuyId == id); var model = new BuyDetail { BuyId = entity.BuyId, RealEstatePropertyId = entity.RealEstatePropertyId, DateAvail = entity.DateAvail, Price = entity.Price, Description = entity.Description, RealEstatePropertyName = entity.Property.RealEstatePropertyName, PropertyType = entity.Property.PropertyType, ImageLink = entity.Property.ImageLink, Stories = entity.Property.Stories, SquareFootage = entity.Property.SquareFootage, RealEstateAddress = entity.Property.RealEstateAddress, RealEstateCity = entity.Property.RealEstateCity, RealEstateState = entity.Property.RealEstateState, RealEstateZip = entity.Property.RealEstateZip, Bedroom = entity.Property.Bedroom, HasBasement = entity.Property.HasBasement, HasPool = entity.Property.HasPool, Bathroom = entity.Property.Bathroom }; return(model); } }
public void BuySmsByAccount(int count, decimal smsPrice, int payAccountWay, string payPassword) { var currentUser = AuthManager.GetCurrentUser(); string code = currentUser.Code; var businessman = businessmanRepository.FindAll(x => x.Code == code).SingleOrDefault(); string InPayNo = businessman.GetPayNo(); // decimal smsPrice = SettingSection.GetInstances().Sms.SmsPrice; decimal payAmount = Math.Round((count * smsPrice), 2); string payResult = string.Empty; BuyDetail buyDetail = new BuyDetail { BuyTime = DateTime.Now, Count = count, Name = currentUser.OperatorName, PayNo = InPayNo, PayAmount = payAmount, PayFee = Math.Round(payAmount * SystemConsoSwitch.Rate, 2) }; if (payAccountWay == 0) { buyDetail.PayWay = EnumPayMethod.Account; //payResult = payMentClientProxy.PaymentByCashAccount(currentUser.CashbagCode, currentUser.CashbagKey, InPayNo, "购买短信", payAmount, payPassword); var result = payMentClientProxy.PaymentByCashAccount(currentUser.CashbagCode, currentUser.CashbagKey, InPayNo, "购买短信", payAmount, payPassword); payResult = result.Item2; } else if (payAccountWay == 1) { buyDetail.PayWay = EnumPayMethod.Credit; //payResult = payMentClientProxy.PaymentByCreditAccount(currentUser.CashbagCode, currentUser.CashbagKey, InPayNo, "购买短信", payAmount, payPassword); var result = payMentClientProxy.PaymentByCreditAccount(currentUser.CashbagCode, currentUser.CashbagKey, InPayNo, "购买短信", payAmount, payPassword); payResult = result.Item2; } if (!string.IsNullOrEmpty(payResult)) { buyDetail.OutPayNo = payResult; buyDetail.BuyState = EnumPayStatus.OK; businessman.SMS.Buy(count); } else { buyDetail.BuyState = EnumPayStatus.NoPay; } buyDetail.PayTime = DateTime.Now; businessman.BuySms(buyDetail); unitOfWorkRepository.PersistUpdateOf(businessman); unitOfWork.Commit(); }
//購入 public ActionResult Confirm() { //メソッド化した方がいいかも List <Cart> li = (List <Cart>)Session["cart"]; if (Session["login"] == null) { return(RedirectToAction("Login", "Members")); } int UserID = (int)Session["login"]; //いつどのユーザーが買ったか Buy b = new Buy() { UserID = UserID, BuyDate = DateTime.Now //ulcnowだと大分違う時間になった サーバーの位置のせい? }; db.Buys.Add(b); db.SaveChanges(); //TODO:今追加したものの自動採番idが欲しい javaのgetGeneratedKeys的なもの無い? //とりあえず自分のIDで最後に入れたものを取得 //エラー LINQ to Entities does not recognize the method 'Int32 Last[Int32](System.Linq.IQueryable`1[System.Int32])' method, and this method cannot be translated into a store expression. //LastをFirstにして並び替える事でエラー回避 var bid = (from a in db.Buys where a.UserID == UserID orderby a.Id descending select a.Id).First(); BuyDetail bd = new BuyDetail(); foreach (var p in li) { bd.BuyID = bid; bd.ProductID = p.Id; bd.Number = p.Number; bd.Price = p.Price; db.BuyDetails.Add(bd); db.SaveChanges(); //追加したらすぐchangeしないと最後の1回分しか登録されなかった } Session.Remove("Cart"); return(RedirectToAction("Index", "Home")); }
//保存按钮 private void buttonSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(_ProfeCode)) { MessageBox.Show("供应商不可为空,请选择供应商!"); return; } BuyManager bm = new BuyManager(); GridItemsCollection grs = superGridControl1.PrimaryGrid.Rows; List <BuyDetail> buyDetailList = new List <BuyDetail>(); Buy buy = new Buy(); if (grs.Count > 1) { buy.Buy_Code = BuyOdd; buy.Buy_Date = dateTimePicker1.Value; buy.Buy_SupplierCode = _ProfeCode; buy.Buy_SupplierName = labtextboxTop2.Text.Trim(); buy.Buy_PurchaseStatus = 1; buy.Buy_AuditStatus = 0; buy.Buy_PurchaserID = "0"; buy.Buy_SalesMan = labtextboxBotton1.Text; buy.Buy_Operation = labtextboxBotton3.Text; buy.Buy_AuditMan = ""; buy.Buy_Remark = labtextboxBotton2.Text; buy.Buy_Clear = 1; buy.Buy_IsPay = 0; buy.Buy_PayMethod = 0; buy.Buy_IsPutSto = 0; buy.Buy_Class = "采购申请单"; //buy.Buy_PayMethod = //buy.Buy_PayMethod = int i = 0; foreach (GridRow gr in grs) { i++; BuyDetail buyDetail = new BuyDetail(); if (gr["gridColumnName"].Value == null) { continue; } if (string.IsNullOrEmpty(gr["gridColumnName"].Value.ToString())) { continue; } if (gr["gridColumnStock"].Value == null || gr["gridColumnStockCode"].Value == null) { MessageBox.Show("货品" + gr["gridColumnName"].Value.ToString() + "仓库未选择,请选择!"); return; } if (gr["gridColumnStock"].Value.ToString() == "" || gr["gridColumnStockCode"].Value.ToString() == "") { MessageBox.Show("货品" + gr["gridColumnName"].Value.ToString() + "仓库未选择,请选择!"); return; } buyDetail.Buy_LineCode = BuyOdd + "_" + i.ToString(); buyDetail.Buy_StockCode = gr["gridColumnStockCode"].Value.ToString(); buyDetail.Buy_StockName = gr["gridColumnStock"].Value.ToString(); buyDetail.Buy_Code = BuyOdd; buyDetail.Buy_MaID = gr["gridColumnMaID"].Value.ToString(); buyDetail.Buy_MaName = gr["gridColumnName"].Value.ToString(); buyDetail.Buy_Model = gr["gridColumnModel"].Value.ToString(); buyDetail.Buy_Unit = gr["gridColumnUnit"].Value.ToString(); buyDetail.Buy_CurNumber = Convert.ToDecimal(gr["gridColumnNumber"].Value); buyDetail.Buy_DiscountAPrice = Convert.ToDecimal(gr["gridColumnPrice"].Value); buyDetail.Buy_Discount = Convert.ToDecimal(gr["gridColumnDis"].Value); buyDetail.Buy_DiscountBPrice = Convert.ToDecimal(gr["gridColumnDisPrice"].Value); buyDetail.Buy_AmountMoney = Convert.ToDecimal(gr["gridColumnMoney"].Value); buyDetail.Buy_Clear = 1; buyDetail.Buy_Remark = gr["gridColumnRemark"].Value == null ? "" : gr["gridColumnRemark"].Value.ToString(); buyDetailList.Add(buyDetail); } try { int influence = bm.AddBatch(buy, buyDetailList); if (influence < 1) { MessageBox.Show("未新增任何数据,请检查是否未录入数据,或是存在数据为空"); } else { MessageBox.Show("申请采购单成功,该单正在等待审核中."); } } catch (Exception ex) { MessageBox.Show("错误代码:3101-创建采购单异常,异常信息:" + ex.Message); } } else { MessageBox.Show("请先在表格内增加需要采购的商品"); } }