//验证并消费 private void BTVerify_Click(object sender, EventArgs e) { string code = TextCode.Text.Trim(); if (code == "") { BathClass.printErrorMsg("需要输入优惠券代码!"); return; } string errorDesc = ""; var consumeWxCouponResult = WxCouponManagement.consumeCoupon(LogIn.connectionIP, LogIn.options.company_Code, code, out errorDesc); if (consumeWxCouponResult == null) { BathClass.printErrorMsg(errorDesc); TextCode.SelectAll(); TextCode.Focus(); return; } if (!consumeWxCouponResult.success) { BathClass.printErrorMsg(consumeWxCouponResult.errorDesc); TextCode.SelectAll(); TextCode.Focus(); return; } couponValue = consumeWxCouponResult.value; this.DialogResult = DialogResult.OK; this.Close(); }
private void dgvUsed_show() { dgvUsed.Rows.Clear(); string errorDesc = ""; var coupons = WxCouponManagement.queryCouponRecords(LogIn.connectionIP, LogIn.options.company_Code, openId, DPStart.Value.ToString("yyyy-MM-dd HH:mm:ss"), DPEnd.Value.ToString("yyyy-MM-dd HH:mm:ss"), out errorDesc); if (coupons == null) { BathClass.printErrorMsg(errorDesc); return; } int i = 1; foreach (var coupon in coupons) { dgvUsed.Rows.Add(i, coupon.id, coupon.title, coupon.value, PCUtil.converJavaTimeToNetTime(coupon.consumeTime)); i++; } BathClass.set_dgv_fit(dgvUsed); dgvUsed.CurrentCell = null; }
//删除 private void ToolDel_Click(object sender, EventArgs e) { if (dgv.CurrentCell == null) { BathClass.printErrorMsg("需要先选择优惠券所在行!"); return; } if (BathClass.printAskMsg("确认删除优惠券?") != DialogResult.Yes) { return; } string errorDesc = ""; string isDeleted = (dgv.CurrentRow.Cells[4].EditedFormattedValue.ToString() == "False" ? "y" : "n"); int id = MConvert <int> .ToTypeOrDefault(dgv.CurrentRow.Cells[0].Value, 0); double value = MConvert <double> .ToTypeOrDefault(dgv.CurrentRow.Cells[2].Value, 0); bool success = WxCouponManagement.uploadCoupon(LogIn.connectionIP, id, LogIn.options.company_Code, value, "", "", isDeleted, out errorDesc); if (!success) { BathClass.printErrorMsg("删除失败,原因:" + errorDesc); } dgv_show(); }
private void BTOk_Click(object sender, EventArgs e) { string value = TextValue.Text.Trim(); if (value == "") { BathClass.printErrorMsg("需要输入金额"); TextValue.SelectAll(); return; } string title = TextTitle.Text.Trim(); if (title == "") { BathClass.printErrorMsg("需要输入优惠券名称!"); return; } string errorDesc = ""; if (wxCoupon == null) { bool success = WxCouponManagement.uploadCoupon(LogIn.connectionIP, 0, LogIn.options.company_Code, MConvert <double> .ToTypeOrDefault(value, 0), TextDescp.Text, title, "n", out errorDesc); if (!success) { BathClass.printErrorMsg("上传失败,原因:" + errorDesc); return; } this.form.dgv_show(); TextTitle.Text = ""; TextValue.Text = ""; TextDescp.Text = ""; TextTitle.Focus(); } else { bool success = WxCouponManagement.uploadCoupon(LogIn.connectionIP, wxCoupon.id, LogIn.options.company_Code, MConvert <double> .ToTypeOrDefault(value, 0), TextDescp.Text, title, "n", out errorDesc); if (!success) { BathClass.printErrorMsg("上传失败,原因:" + errorDesc); return; } this.DialogResult = DialogResult.OK; this.Close(); } }
private void dgv_show() { string errorDesc = ""; var coupons = WxCouponManagement.getCoupon(LogIn.connectionIP, LogIn.options.company_Code, out errorDesc); if (coupons == null) { BathClass.printErrorMsg(errorDesc); return; } foreach (var coupon in coupons) { dgv.Rows.Add(coupon.id, coupon.title, coupon.value); } dgv.CurrentCell = null; }
private void dgvUnUsed_show() { string errorDesc = ""; var coupons = WxCouponManagement.queryCouponByUser(LogIn.connectionIP, LogIn.options.company_Code, openId, out errorDesc); if (coupons == null) { BathClass.printErrorMsg(errorDesc); return; } dgvUnUsed.Rows.Clear(); int i = 1; foreach (var coupon in coupons.unUseList) { dgvUnUsed.Rows.Add(i, coupon.id, coupon.title, coupon.count); i++; } BathClass.set_dgv_fit(dgvUnUsed); }
//赠送 private void BTExtend_Click(object sender, EventArgs e) { if (wxUser == null) { BathClass.printErrorMsg("需要选择赠送对象!"); return; } if (dgv.CurrentCell == null) { BathClass.printErrorMsg("需要选择赠送优惠券种类!"); return; } string errorDesc = ""; var couponIds = new List <int>(); var openIds = new List <string>(); var numbers = new List <int>(); foreach (DataGridViewRow r in dgvExtend.Rows) { couponIds.Add(MConvert <int> .ToTypeOrDefault(r.Cells[2].Value, 0)); openIds.Add(r.Cells[0].Value.ToString()); numbers.Add(MConvert <int> .ToTypeOrDefault(r.Cells[4].Value, 1)); } bool success = WxCouponManagement.extendMultiCoupon(LogIn.connectionIP, LogIn.options.company_Code, couponIds, openIds, numbers, out errorDesc); if (!success) { BathClass.printErrorMsg(errorDesc); return; } BathClass.printInformation("优惠券赠送成功!"); this.DialogResult = DialogResult.OK; this.Close(); }
public void dgv_show() { dgv.Rows.Clear(); string errorDesc = ""; var coupons = WxCouponManagement.queryCouponByCompany(LogIn.connectionIP, LogIn.options.company_Code, out errorDesc); if (coupons == null) { BathClass.printErrorMsg(errorDesc); return; } int i = 1; foreach (var coupon in coupons) { string type = coupon.isConsume == "y" ? "已用" : "未用"; dgv.Rows.Add(i, coupon.id, coupon.title, type, coupon.count); i++; } dgv.CurrentCell = null; }