public bool UpdateMemberPrice(MemberPrice memberPrice) { string sql = @"INSERT into gsm_member_price(goods_id, user_rank, user_price) values(@GoodsId, @UserRank, @UserPrice) ON DUPLICATE KEY UPDATE user_price = VALUES(user_price)"; MySqlParameter[] pars = { new MySqlParameter("@GoodsId", memberPrice.GoodsId), new MySqlParameter("@UserRank", memberPrice.UserRank), new MySqlParameter("@UserPrice", memberPrice.UserPrice) }; var result = MySqlHelper.ExecuteNonQuery(AppSetting.ServerConnectionString, sql, pars); return(result > 0); }
public static void Main(string[] args) { var bronzeMemberDiscount = new MemberPrice(1, 1, 1); var silverMemberDiscount = new MemberPrice(2, 2, 2); var goldMemberDiscount = new MemberPrice(3, 3, 3); var goodPrice = bronzeMemberDiscount.Clone(); var regularWholeSellerDiscount = new WholeSellerPrice(2, false); var partneredWholeSellerDiscount = new WholeSellerPrice(2, true); var betterPrice = regularWholeSellerDiscount.Clone(); var regularBronze = regularWholeSellerDiscount.Concat(bronzeMemberDiscount); var bestPrice = regularBronze.Clone(); Console.ReadKey(); }
//修改单元格数据事件 private void dgvWebGoods_CellEndEdit(object sender, DataGridViewCellEventArgs e) { switch (e.ColumnIndex) { case 0: case 1: case 2: case 3: case 4: case 5: //修改gsm_goods表的数据 if (dgvWebGoods.Rows.Count > 0) { Goods goods = new Goods(); goods.Id = int.Parse(this.dgvWebGoods.Rows[e.RowIndex].Cells[0].Value.ToString()); goods.No = this.dgvWebGoods.Rows[e.RowIndex].Cells[1].Value.ToString(); goods.Name = this.dgvWebGoods.Rows[e.RowIndex].Cells[2].Value.ToString(); goods.PCS = int.Parse(this.dgvWebGoods.Rows[e.RowIndex].Cells[3].Value.ToString()); goods.StorePCS = int.Parse(this.dgvWebGoods.Rows[e.RowIndex].Cells[4].Value.ToString()); var result = goodsService.UpdateGoodsInfo(goods); if (!result) { MessageBox.Show("更新数据库失败,出现异常"); } } break; case 6: //修改vip价格 if (dgvWebGoods.Rows.Count > 0) { MemberPrice memberVipPrice = new MemberPrice(); memberVipPrice.GoodsId = int.Parse(this.dgvWebGoods.Rows[e.RowIndex].Cells[0].Value.ToString()); memberVipPrice.UserRank = 2; string vipPriceStr = this.dgvWebGoods.Rows[e.RowIndex].Cells[7].Value.ToString(); if (vipPriceStr == "") { memberVipPrice.UserPrice = 0; } else { try { memberVipPrice.UserPrice = float.Parse(vipPriceStr); } catch (Exception) { MessageBox.Show("输入的vip价格无效"); } } memberVipPrice.UserPrice = float.Parse(this.dgvWebGoods.Rows[e.RowIndex].Cells[6].Value.ToString()); var result = memberPriceService.UpdateMemberPrice(memberVipPrice); if (!result) { MessageBox.Show("更新数据库失败,出现异常"); } } break; case 7: //修改批发价格 if (dgvWebGoods.Rows.Count > 0) { MemberPrice memberPrice = new MemberPrice(); memberPrice.GoodsId = int.Parse(this.dgvWebGoods.Rows[e.RowIndex].Cells[0].Value.ToString()); memberPrice.UserRank = 3; string wholesalePrice = this.dgvWebGoods.Rows[e.RowIndex].Cells[7].Value.ToString(); if (wholesalePrice == "") { memberPrice.UserPrice = 0; } else { try { memberPrice.UserPrice = float.Parse(wholesalePrice); } catch (Exception) { MessageBox.Show("输入的批发价格无效"); } } //调用服务更新数据 var result = memberPriceService.UpdateMemberPrice(memberPrice); if (!result) { MessageBox.Show("更新数据库失败,出现异常"); } } break; } }
public bool UpdateMemberPrice(MemberPrice memberPrice) { return(memberPriceDal.UpdateMemberPrice(memberPrice)); }