private void btnCardAdd_Click(object sender, EventArgs e) { try { if (dataGridView1.SelectedRows.Count > 0) { vwAssCard ass = dataGridView1.SelectedRows[0].DataBoundItem as vwAssCard; if (ass.cCardState != "2") { throw new Exception("此会员卡无法做补卡操作"); } frmCardAdd cardAdd = new frmCardAdd(); cardAdd.AssCardID = ass.vcAssCardID; cardAdd.AssID = ass.iAssID; cardAdd.MinimizeBox = false; cardAdd.MaximizeBox = false; cardAdd.ShowDialog(); } else { MessageBox.Show(this, "请查询或搜索会员,并选择会员", "提示"); } } catch (Exception ex) { ErrorLog.Write(this, ex); } }
private void btnCardLose_Click(object sender, EventArgs e) { try { if (dataGridView1.SelectedRows.Count > 0) { vwAssCard ass1 = dataGridView1.SelectedRows[0].DataBoundItem as vwAssCard; tbAssociator ass = null; tbAssociatorCard assCard = null; tbIntegral ig = null; using (AMSEntities amsContext = new AMSEntities()) { //数据操作 ass = amsContext.tbAssociator.FirstOrDefault(a => a.iAssID == ass1.iAssID); assCard = amsContext.tbAssociatorCard.FirstOrDefault(a => a.iAssID == ass1.iAssID && a.vcAssCardID == ass1.vcAssCardID); ig = amsContext.tbIntegral.FirstOrDefault(i => i.iAssID == ass1.iAssID && i.vcAssCardID == ass1.vcAssCardID); } if (ass == null) { throw new Exception("未找到会员信息"); } if (assCard == null) { throw new Exception("未找到会员卡信息"); } if (assCard.cCardState != ConstApp.CST_1) { throw new Exception("此会员卡无法做挂失操作"); } if (ass.vcAssState != ConstApp.AST_1) { throw new Exception("此会员无法做挂失操作"); } if (ig == null) { throw new Exception("获取会员积分信息错误无法做挂失"); } frmCardLose cardLose = new frmCardLose(); cardLose.ass = ass; cardLose.assCard = assCard; cardLose.ig = ig; cardLose.ControlBox = false; cardLose.ShowDialog(); } else { Helper.ShowInfo(this, "请查询或搜索会员,并选择会员"); } } catch (Exception ex) { ErrorLog.Write(this, ex); } }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex > -1 && e.RowIndex > -1) { if (dataGridView1.SelectedRows.Count > 0) { vwAssCard assCard = dataGridView1.SelectedRows[0].DataBoundItem as vwAssCard; tbAssociator ass = null; using (AMSEntities amsContext = new AMSEntities()) { //数据操作 ass = amsContext.tbAssociator.FirstOrDefault(a => a.iAssID == assCard.iAssID); } if (ass == null) { throw new Exception("未找到会员信息"); } frmAss frmass = new frmAss(); frmass.ass = ass; frmass.OperType = "DETAIL"; frmass.MinimizeBox = false; frmass.MaximizeBox = false; frmass.ShowDialog(); } else { Helper.ShowInfo(this, "请查询或搜索会员,并选择会员"); } } } catch (Exception ex) { ErrorLog.Write(this, ex); } }
private void btnCardCallback_Click(object sender, EventArgs e) { DbConnection conn = null; DbTransaction trans = null; try { if (dataGridView1.SelectedRows.Count > 0) { vwAssCard ass1 = dataGridView1.SelectedRows[0].DataBoundItem as vwAssCard; if (ass1.cCardState != ConstApp.CST_0) { throw new Exception("此会员卡无法做卡回收操作"); } using (AMSEntities amsContext = new AMSEntities()) { conn = amsContext.Connection; if (conn.State != ConnectionState.Open) { conn.Open(); } using (trans = conn.BeginTransaction(IsolationLevel.ReadCommitted)) { //事务数据操作或其它一致性操作 tbAssociator ass = amsContext.tbAssociator.FirstOrDefault(a => a.iAssID == ass1.iAssID); tbAssociatorCard assCard = amsContext.tbAssociatorCard.FirstOrDefault(a => a.iAssID == ass1.iAssID && a.vcAssCardID == ass1.vcAssCardID); //tbIntegral ig = amsContext.tbIntegral.FirstOrDefault(i => i.vcAssCardID == assCard.vcAssCardID && i.iAssID == assCard.iAssID); if (ass == null) { throw new Exception("未找到会员信息"); } if (assCard == null) { throw new Exception("未找到会员卡信息"); } //if (ig == null) // throw new Exception("获取会员卡积分错误,请重试"); string strInfo = "会员卡号:" + assCard.vcAssCardID + "\n会员姓名:" + ass.vcAssName //+ "\n当前余额:" + ig.nBalance + "\n身份证号:" + ass.vcAssNbr + "\n公司名称:" + ass.vcCompanyName; if (DialogResult.Yes == MessageBox.Show(this, strInfo, "卡回收信息确认", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { assCard.cCardState = ConstApp.CST_4; assCard.dtCardExpDate = DateTime.Now; assCard.vcOperID = GlobalParams.oper.vcOperID; assCard.dtOperDate = DateTime.Now; tbBusiLog busiLog = new tbBusiLog(); busiLog.dtOperDate = DateTime.Now; busiLog.iAssID = assCard.iAssID; busiLog.vcAssCardID = assCard.vcAssCardID; busiLog.vcAssName = ass.vcAssName; busiLog.vcOperName = GlobalParams.oper.vcOperName; busiLog.vcOperID = GlobalParams.oper.vcOperID; busiLog.vcOperType = "OT006"; //busiLog.vcLinkSerial = billInvoice.iBillNo; amsContext.AddTotbBusiLog(busiLog); Helper.Save(amsContext); //写卡,卡为原始状态 trans.Commit(); Helper.ShowInfo(this, "会员卡回收成功"); } } } } else { Helper.ShowInfo(this, "请查询或搜索会员,并选择会员"); } } catch (Exception ex) { ErrorLog.Write(this, ex); } finally { if (conn != null) { conn.Close(); } } }