//验证并消费 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 BTAdd_Click(object sender, EventArgs e) { var code = TextCode.Text.Trim(); if (code == "") { MessageBox.Show("需要输入内容!"); return; } if (!StringUtil.isEmpty(companies.FirstOrDefault(x => x.Split(Constants.SplitChar)[0] == code))) { MessageBox.Show("已经包含该店铺,不能重复添加!"); return; } //需要连接服务器检验code是否存在! string errorDesc = ""; var customer = ShopManagement.queryCustomer(MainForm.ip, code, out errorDesc); if (customer == null) { if (!StringUtil.isEmpty(errorDesc)) { MessageBox.Show(errorDesc); } else { MessageBox.Show("该店铺代码不存在,请确认!"); TextCode.SelectAll(); TextCode.Focus(); } return; } //companyCodes.Add(code); companies.Add(joinCustomer(customer)); IOUtil.set_config_by_key(ConfigKeys.KEY_COMPANY_CODE, string.Join(Constants.BIG_SPLITCHAR.ToString(), companies.ToArray())); dgv_show(); TextCode.Text = ""; TextCode.Focus(); }