private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (listView1.SelectedIndices.Count > 0) { int inde = listView1.SelectedIndices[0]; COM.CreateSQL GetInfo = new COM.CreateSQL(wa_code.FormName, wa_wash.FormName); GetInfo.SelectInit(wa_code.cardid, wa_code.Wphone, wa_code.fromdate,wa_wash.XiaCi, wa_wash.todate, wa_wash.mark); GetInfo.AddAnd(wa_wash.Wnumber +"=" + wa_code.COID ); GetInfo.AddAnd(wa_wash.WID , "=" ,listView1.Items[inde].SubItems[9].Text); int cardId = -1; using (IDataReader idr = GetInfo.SelectExec(null)) { if (idr == null || !idr.Read()) { label2.Text = "详细信息读取失败!"; label3.Text = ""; return; } label2.Text = "顾客姓名:" + listView1.Items[inde].SubItems[1].Text; if ((int)idr[wa_code.cardid] != -1) { cardId = (int)idr[wa_code.cardid]; label3.Text = "卡 号:" + cardId; } else label3.Text = "卡 号:无"; label2.Text += "\n顾客电话:" + idr[wa_code.Wphone]; label3.Text += "\n备 注:" + idr[wa_wash.mark]; label2.Text += "\n收衣日期:" + idr[wa_code.fromdate]; label3.Text += "\n取衣日期:" + idr[wa_wash.todate]; label2.Text += "\n瑕 疵:" + idr[wa_wash.XiaCi]; } if(cardId>0) { double deposit = sql.VIP.GetDepositByCardId(cardId); label3.Text += "\n余 额:" + deposit; } } }
/// <summary> /// 将获取的洗衣数据填充之ListView, /// </summary> /// <param name="Lv">目标</param> /// <param name="AndSql">sql语句and条件</param> /// <param name="AutoCheck">是否自动打勾</param> /// <returns></returns> public static bool GetAllCode(ListView Lv, string AndSql,ref int shopId, bool AutoCheck = false) { COM.CreateSQL GetAlls = new COM.CreateSQL(wa_code.FormName, wa_wash.FormName); GetAlls.SelectInit(wa_code.COID,wa_code.Wname,wa_code.shopID,wa_wash.WID,wa_wash.XiangMu,wa_wash.YangShi,wa_wash.color,wa_wash.JiaGe,wa_wash.number,wa_wash.discount,wa_wash.FuKuan,wa_wash.toID,wa_wash.GuaDian,wa_wash.CPay); GetAlls.AddAnd(wa_wash.Wnumber + "=" + wa_code.COID + " and " + AndSql); GetAlls.OrderDesc(wa_code.COID); GetAlls.Limit(100); using (IDataReader idr = GetAlls.SelectExec(null)) { Lv.Items.Clear(); if (idr == null) { MessageBox.Show("读取失败:" + Mysqlcom.error, "错误"); return false; } int i = 0; for (; idr.Read(); i++) { shopId = (int)idr[wa_code.shopID]; //编号 Lv.Items.Add(idr[wa_code.COID].ToString()); ///姓名 Lv.Items[i].SubItems.Add(idr[wa_code.Wname].ToString()); ///项目 Lv.Items[i].SubItems.Add(idr[wa_wash.XiangMu].ToString()); ////颜色+样式 Lv.Items[i].SubItems.Add(idr[wa_wash.color].ToString() + idr[wa_wash.YangShi].ToString()); ///挂点 // listView1.Items[i].SubItems.Add(""); ///挂点 if ((int)idr[wa_wash.GuaDian] == -1) Lv.Items[i].SubItems.Add("无"); else Lv.Items[i].SubItems.Add(idr[wa_wash.GuaDian].ToString()); ///数量 Lv.Items[i].SubItems.Add(idr[wa_wash.number].ToString()); ///总价 Lv.Items[i].SubItems.Add(idr[wa_wash.CPay].ToString()); ///付款 Lv.Items[i].SubItems.Add(idr[wa_wash.FuKuan].ToString()); ///付衣 if (idr[wa_wash.toID].ToString() == "") { Lv.Items[i].SubItems.Add("未取"); if (AutoCheck) Lv.Items[i].Checked = true; } else { Lv.Items[i].SubItems.Add("已取"); Lv.Items[i].ForeColor = System.Drawing.Color.DarkGray; } ///WID Lv.Items[i].SubItems.Add(idr[wa_wash.WID].ToString()); ///折扣 Lv.Items[i].SubItems.Add(idr[wa_wash.discount].ToString()); ///单价 Lv.Items[i].SubItems.Add(idr[wa_wash.JiaGe].ToString()); } if (i == 0) { MessageBox.Show("没有找到此内容", "错误"); return false; } } return true; }