//查询固定卡收费 private void btnv_Click(object sender, EventArgs e) { try { txtFeeStandard.Text = ""; txtIccdType.Text = ""; txtCurrDue.Text = ""; nudmcnt.Value = 0; if (txtfixcd.Text.Trim() != "") { CICCard iccd = Program.mng.SelectByUserCode(txtfixcd.Text.Trim()); if (iccd != null) { string type = ""; switch (iccd.Type) { case EnmICCardType.Temp: type = "临时卡"; break; case EnmICCardType.Fixed: type = "定期卡"; break; case EnmICCardType.FixedLocation: type = "固定车位卡"; break; } txtIccdType.Text = type; txtCurrDue.Text = iccd.DueDtime.ToString(); btnFixFee.Enabled = true; //构建收费记录 tempFixLog = new CFixCardChargeLog(); tempFixLog.ICCode = iccd.Code; tempFixLog.ICType = iccd.Type; tempFixLog.DueDtime = iccd.DueDtime; rdMonth.Checked = true; lstTariffs = new List <CTariff>(Program.mng.SelectTariff()); //加载收费标准 if (lstTariffs != null) { CTariff tari = lstTariffs.Find(t => t.Type == tempFixLog.ICType && t.Unit == EnmFeeUnit.Month); if (tari != null) { txtFeeStandard.Text = tari.Fee.ToString(); } } } else { MessageBox.Show("该卡不是系统卡!"); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// 固定卡的临时收费 /// </summary> /// <param name="iccode"></param> /// <param name="fxLog"></param> /// <returns></returns> public int GetFixCardCurrentFee(string iccode, out CFixCardChargeLog fxLog) { fxLog = null; CICCard iccd = this.SelectByUserCode(iccode); if (iccd == null) { return(101); //不是本系统用卡 } if (iccd.Type != CICCard.EnmICCardType.Temp) { return(102); //该卡不是临时卡 } CLocation lct = new CWLocation().SelectLctFromICCode(iccode); if (lct == null) { return(103); //该卡没有存车 } fxLog = new CFixCardChargeLog(); fxLog.ICCode = iccd.Code; fxLog.InDate = lct.InDate; fxLog.RecivFee = new CWTariff().CalculateCardFee(DateTime.Now - fxLog.InDate); return(100); }
//挂失、注销卡 public int UpdateICCardStatus(string code, CICCard.EnmICCardStatus status) { try { CICCard iccd = this.SelectByUserCode(code); if (iccd == null) { return(101); } if (status == CICCard.EnmICCardStatus.Lost) { iccd.LossDtime = DateTime.Now; } else if (status == CICCard.EnmICCardStatus.Disposed) { iccd.DisposeDtime = DateTime.Now; } else if (status == CICCard.EnmICCardStatus.Normal) { iccd.LossDtime = CObject.DefDatetime; iccd.DisposeDtime = CObject.DefDatetime; } iccd.Status = status; CWData.myDB.UpdateIccardStat(iccd); return(100); } catch (Exception ex) { new CWSException(); throw ex; } }
/// <summary> /// 删除顾客 /// </summary> public int DeleteCustomer(int custID, string ccode) { try { CICCard iccd = this.SelectByUserCode(ccode); CLocation lct = new CWLocation().SelectLctFromICCode(iccd.Code); if (lct != null) { return(101); //该卡在存车 } iccd.CustomerID = 0; iccd.DueDtime = CObject.DefDatetime; iccd.PlatNumber = ""; iccd.Address = ""; iccd.Type = CICCard.EnmICCardType.Temp; CWData.myDB.DeleteCustomer(iccd, custID); return(100); } catch (Exception ex) { new CWSException(); throw ex; } }
/// <summary> /// 制卡 /// </summary> /// <param name="iccd">新卡对象</param> /// <returns></returns> public int InsertICCard(CICCard iccd) { try { CICCard iccd1 = this.SelectByPhysicCard(iccd.PhysicCode); //物理卡号是否重复 CICCard iccd2 = this.SelectByUserCode(iccd.Code); //用户卡号是否重复 if (iccd1 == null) { if (iccd2 == null) { CWData.myDB.InsertICCard(iccd); ICCards.Add(iccd); } //else if (iccd2.Status == CICCard.EnmICCardStatus.Disposed) //用户卡号已注销,则卡号就可再利用-----------屏蔽,有问题 //{ // CWData.myDB.InsertICCard(iccd); // ICCards.Add(iccd); //} else { return(101); //物理卡不存在,用户卡号已存在 } } else //物理卡存在 { if (iccd2 == null) //用户卡不存在,则更新 { iccd1.Code = iccd.Code; iccd1.Status = iccd.Status; iccd1.Type = iccd.Type; CWData.myDB.UpdateICCard(iccd1); } else //用户卡存在 { if (iccd1.Code == iccd2.Code) { iccd1.Status = iccd.Status; iccd1.Type = iccd.Type; CWData.myDB.UpdateICCard(iccd1); } else { return(102); //物理卡存在,用户卡号存在 } } } return(100); } catch (Exception ex) { new CWSException(); throw ex; } }
/// <summary> /// 返回所有的用户 /// </summary> /// <returns></returns> public CCustomer[] SelectAllCustomers() { List <CCustomer> customers = CWData.myDB.LoadCustomers(); foreach (CCustomer cust in customers) { CICCard iccd = new CICCard(); iccd = ICCards.Find(c => c.CustomerID == cust.ID); cust.SetICCard(iccd); } return(customers.ToArray()); }
/// <summary> /// 手动入库 /// </summary> public int ManInLocation(string addrs, string iccode, string carSize, int distance, DateTime InDate) { try { CLocation lct = this.SelectLctFromAddrs(addrs); CICCard iccd = new CICCard(); //在使用seticcard时是对象间赋值,应先生成新对象, iccd = new CWICCard().SelectByUserCode(iccode); if (lct == null || iccd == null) { return(101); } if (iccd.Status != CICCard.EnmICCardStatus.Normal) { return(106); } if (lct.Type != CLocation.EnmLocationType.Normal || lct.Status != CLocation.EnmLocationStatus.Space) { return(102); //该车位不合格 } if (lct.ICCardCode != "") { return(103); //车位上有车 } CLocation lctn = this.SelectLctFromICCode(iccd.Code); if (lctn != null) { return(104); //该卡已存车 } if (carSize.CompareTo(lct.Size) > 0) { return(105);//外形不合格 } lct.SetICCard(iccd); lct.Distance = distance; lct.CarSize = carSize; lct.InDate = InDate; lct.Status = CLocation.EnmLocationStatus.Occupy; string msg = "数据入库- 源车位:" + lct.Address + " 状态:" + lct.Status.ToString() + " 卡号:" + lct.ICCardCode; new CWSException(msg, 0); CWData.myDB.ManUpdateLocation(lct); return(100); } catch (Exception ex) { HttpRuntime.Cache.Remove("CLocations"); throw ex; } }
/// <summary> /// 更新缴费 /// </summary> /// <param name="nfcdlog"></param> /// <returns></returns> public int SetFixCardFee(CFixCardChargeLog nfcdlog) { try { CICCard iccd = this.SelectByUserCode(nfcdlog.ICCode); iccd.DueDtime = nfcdlog.DueDtime; CWData.myDB.UpdateICCardAndLog(iccd, nfcdlog); return(100); } catch (Exception e1) { new CWSException(); throw e1; } }
/// <summary> /// 增加新顾客 /// </summary> public int InsertCustomer(CCustomer nctm, CICCard iccd) { try { CWLocation wlctn = new CWLocation(); CICCard oicd = this.SelectByUserCode(iccd.Code); if (oicd.CustomerID != 0 || oicd.Status == CICCard.EnmICCardStatus.Lost || oicd.Status == CICCard.EnmICCardStatus.Disposed) { return(101); //该卡不可用 } if (wlctn.SelectLctFromICCode(oicd.Code) != null) { return(102); //该卡已用于存车 } if (oicd.Type == CICCard.EnmICCardType.FixedLocation) { if (this.FindFixICCard(oicd.Address) != null) { return(103); //新卡已被其车位绑定 } } oicd.PlatNumber = iccd.PlatNumber; //更新 oicd.DueDtime = iccd.DueDtime; oicd.Type = iccd.Type; oicd.Status = iccd.Status; oicd.Address = iccd.Address; CWData.myDB.InsertCustomer(nctm, oicd); return(100); } catch (Exception ex) { new CWSException(); throw ex; } }
/// <summary> /// 查询临时卡收费 /// </summary> /// <param name="iccode">卡号</param> /// <param name="tempLog">收费对象</param> /// <returns></returns> public int GetTempCardUserInfo(string iccode, out CTempCardChargeLog tempLog) { tempLog = null; CICCard iccd = this.SelectByUserCode(iccode); if (iccd == null) { return(101); //不是本系统用卡 } if (iccd.Type != CICCard.EnmICCardType.Temp) { return(102); //该卡不是临时卡 } CLocation lct = new CWLocation().SelectLctFromICCode(iccode); if (lct == null) { return(103); //该卡没有存车 } CMasterTask mtsk = new CWTask().GetMasterTaskFromICCode(iccode); if (mtsk != null) { return(104); //该卡正在作业 } tempLog = new CTempCardChargeLog(); tempLog.ICCode = iccode; tempLog.LocationAddress = lct.Address; tempLog.InDate = lct.InDate; tempLog.OutDate = DateTime.Now; tempLog.RecivFee = new CWNewTrariff().CalculateTempFee(tempLog.InDate, tempLog.OutDate); return(100); }
/// <summary> /// 更新用户信息,如果原卡号与更新卡号不一致,则释放原卡号 /// </summary> public int UpdateCustomInfo(CCustomer nctm, CICCard nIccd, string oriCode) { try { CWLocation wlctn = new CWLocation(); CICCard oriIccd = this.SelectByUserCode(oriCode); //原卡 if (oriIccd.Code != nIccd.Code) //原卡与新卡不一致 { if (nIccd.Status == CICCard.EnmICCardStatus.Lost || nIccd.Status == CICCard.EnmICCardStatus.Disposed) { return(101); } if (nIccd.CustomerID != 0) { return(102); //一卡只允许一个人用 } } if (nIccd.Type == CICCard.EnmICCardType.FixedLocation && oriIccd.Address != nIccd.Address) //车位不一致 { if (this.FindFixICCard(nIccd.Address) != null) { return(104); //新卡已被其车位绑定 } } if (wlctn.SelectLctFromICCode(nIccd.Code) != null) { return(103); //该卡已存车 } if (oriIccd.Code != nIccd.Code) { //释放新卡 oriIccd.CustomerID = 0; oriIccd.DueDtime = CObject.DefDatetime; oriIccd.Type = CICCard.EnmICCardType.Temp; oriIccd.Address = ""; oriIccd.PlatNumber = ""; CICCard iccrd = this.SelectByUserCode(nIccd.Code); iccrd = nIccd; //更新新卡号 } else { oriIccd.PlatNumber = nIccd.PlatNumber; oriIccd.DueDtime = nIccd.DueDtime; oriIccd.Status = nIccd.Status; oriIccd.Type = nIccd.Type; oriIccd.Address = nIccd.Address; oriIccd.CustomerID = nIccd.CustomerID; } CWData.myDB.UpdateCustAndICcard(nctm, oriIccd, nIccd); return(100); } catch (Exception ex) { new CWSException(); throw ex; } }
//IC卡查询 private void btnCheck_Click(object sender, EventArgs e) { Control.ControlCollection coll = groupBox4.Controls; for (int i = 0; i < coll.Count; i++) { if (coll[i].GetType() == typeof(TextBox)) { coll[i].Text = ""; } } btnLoss.Enabled = false; btnDisLoss.Enabled = false; btnDispose.Enabled = false; txtPhysicCode.Text = ""; try { CICCard iccd = Program.mng.SelectByUserCode(txtUseCode.Text.Trim()); if (iccd != null) { groupBox4.Enabled = true; txtcd.Text = iccd.Code; txtmdt.Text = iccd.CreateDtime.ToString(); string type = ""; switch (iccd.Type) { case EnmICCardType.Temp: type = "临时卡"; break; case EnmICCardType.Fixed: type = "定期卡"; break; case EnmICCardType.FixedLocation: type = "固定卡"; break; default: type = ""; break; } txttype.Text = type; string stat = ""; switch (iccd.Status) { case EnmICCardStatus.Normal: stat = "正常"; btnLoss.Enabled = true; btnDisLoss.Enabled = false; btnDispose.Enabled = true; break; case EnmICCardStatus.Lost: stat = "挂失"; btnLoss.Enabled = false; btnDisLoss.Enabled = true; btnDispose.Enabled = false; break; case EnmICCardStatus.Disposed: stat = "注销"; btnLoss.Enabled = false; btnDisLoss.Enabled = false; btnDispose.Enabled = false; break; case EnmICCardStatus.Init: stat = "Init"; break; } txtStat.Text = stat; txtldt.Text = iccd.LossDtime.ToString(); txtddt.Text = iccd.DisposeDtime.ToString(); if (iccd.Type == EnmICCardType.FixedLocation) { textlct.Text = iccd.Address; } } else { txtUseCode.Text = ""; //不存在此卡时,清除卡号 } } catch (Exception ex) { MessageBox.Show("异常:" + ex.ToString()); } }
//制卡 private void btnMake_Click(object sender, EventArgs e) { if (txtUseCode.Text.Trim().Length != 4) { MessageBox.Show("请输入正确的4位数卡号!"); return; } txtPhysicCode.Text = ""; CICCardRW mcIccObj = new CIcCardRWOne(iccdCom, 38400, 0, 0); try { bool isConn = false; try { isConn = mcIccObj.ConnectCOM(); } catch (Exception ex) { MessageBox.Show("操作台刷卡器建立连接异常:" + ex.ToString()); } if (isConn) { int nback = 0; Int16 nICType = 0; uint ICNum = 0; byte[] Icdata = new byte[16]; CICCard obj = null; nback = mcIccObj.RequestICCard(ref nICType); //初始化寻卡功能 if (nback == 0) { nback = mcIccObj.SelectCard(ref ICNum);//读取卡号 if (nback == 0) { txtPhysicCode.Text = ICNum.ToString(); obj = new CICCard(); obj.Code = txtUseCode.Text.Trim(); obj.CreateDtime = DateTime.Now; obj.Type = EnmICCardType.Temp; obj.Status = EnmICCardStatus.Normal; obj.PhysicCode = ICNum.ToString(); int rit = Program.mng.InsertICCard(obj); //插入卡号 if (rit == 100) { //向IC卡芯片写入信息 string str = obj.Code + "1" + DateTime.Now.ToString("yyyyMMdd") + "01";//4位数卡号、类型、制卡时间、收费标准 str = str + "fffffffffffffffff"; byte[] b = new byte[16]; mcIccObj.TransStringTo16Char(str, ref b); mcIccObj.WriteCard(1, 0, b, ref nback); //1为扇区,0为扇区数据块 if (nback == 0) { MessageBox.Show("卡操作成功!"); } else { MessageBox.Show("录入卡成功,但写操作失败:" + nback.ToString()); } } else { switch (rit) { case 101: MessageBox.Show("存在相同的用户卡号!"); break; case 102: MessageBox.Show("出现重复的用户卡号!"); break; default: MessageBox.Show("制卡异常,无法完成操作!"); break; } txtUseCode.Text = ""; } } } if (nback != 0) { MessageBox.Show("写数据失败,代码:" + nback.ToString(), "写操作失败"); } } mcIccObj.disConnectCOM(); } catch (Exception e1) { MessageBox.Show(e1.ToString()); } }
//保存 private void btnsv_Click(object sender, EventArgs e) { if (txtname.Text.Trim() == "" || txtcode.Text.Trim() == "") { MessageBox.Show("姓名、发卡编号不允许为空!"); return; } if (comboBox1.SelectedIndex == 3 && txtlct.Text.Trim() == "") { MessageBox.Show("请输入车位地址!"); return; } CICCard iccd = new CICCard(); iccd = Program.mng.SelectByUserCode(txtcode.Text.Trim()); //初步判断 if (iccd == null) { MessageBox.Show("发卡编号不存在!"); return; } if (comboBox1.SelectedIndex == 3 && (Program.mng.CheckFixLocationAvail(txtlct.Text.Trim()) == false)) //初步判断 { MessageBox.Show("请输入正确的车位地址!"); return; } cust.Code = txtname.Text.Trim(); cust.Telphone = txttel.Text.Trim(); cust.Mobile = txtMobile.Text.Trim(); cust.Address = txtads.Text.Trim(); iccd.PlatNumber = txtpnmb.Text.Trim(); iccd.DueDtime = DateTime.Now; //卡状态 if (radioButtonNormal.Checked == true) { iccd.Status = EnmICCardStatus.Normal; } else if (radioButtonLoss.Checked == true) { iccd.Status = EnmICCardStatus.Lost; } //卡类型 if (comboBox1.SelectedIndex == 3) { iccd.Address = txtlct.Text.Trim(); iccd.Type = EnmICCardType.FixedLocation; } else if (comboBox1.SelectedIndex == 2) { iccd.Address = ""; iccd.Type = EnmICCardType.Fixed; } else { iccd.Address = ""; iccd.Type = EnmICCardType.Temp; } if (custID != 0) //更新 { iccd.CustomerID = cust.ID; string iccode = cust.ICCardCode; int rit = Program.mng.UpdateCustomInfo(cust, iccd, iccode); if (rit == 100) { MessageBox.Show("保存成功!"); this.Close(); } else { #region switch (rit) { case 101: MessageBox.Show("当前卡号已注销或挂失!"); break; case 102: MessageBox.Show("当前卡号已绑定其它用户!"); break; case 103: MessageBox.Show("操作失败,该卡已存车,请等待出车完成后再操作!"); break; case 104: MessageBox.Show("该卡已绑定了其他车位!"); break; } if (rit == 0) { MessageBox.Show("系统异常,操作失败!"); this.Close(); } #endregion } } else //新增 { int rit = Program.mng.InsertCustomer(cust, iccd); if (rit == 100) { MessageBox.Show("保存成功!"); this.Close(); } else { #region switch (rit) { case 101: MessageBox.Show("当前卡号已注销或挂失或已被其他顾客使用!"); break; case 102: MessageBox.Show("操作失败,该卡已存车,请等待出车完成后再操作!"); break; case 103: MessageBox.Show("该卡已绑定了其他车位!"); break; } if (rit == 0) { MessageBox.Show("系统异常,操作失败!"); this.Close(); } #endregion } } }
/// <summary> /// 车位数据的手动挪移 /// </summary> /// <param name="fAddrs"></param> /// <param name="tAddrs"></param> /// <returns></returns> public int ManualTransposeLocation(string fAddrs, string tAddrs) { try { CLocation frLct = this.SelectLctFromAddrs(fAddrs); CLocation toLct = this.SelectLctFromAddrs(tAddrs); if (frLct != null && toLct != null) { if (frLct.Type == CLocation.EnmLocationType.Normal && toLct.Type == CLocation.EnmLocationType.Normal) { if (frLct.Status != CLocation.EnmLocationStatus.Occupy) { return(103); } if (toLct.Status != CLocation.EnmLocationStatus.Space) { return(104); } if (frLct.CarSize.CompareTo(toLct.Size) > 0) { return(105); } if (frLct.ICCardCode == "") { return(103); } CICCard iccd = new CICCard(); iccd = new CWICCard().SelectByUserCode(frLct.ICCardCode); toLct.SetICCard(iccd); toLct.Status = CLocation.EnmLocationStatus.Occupy; toLct.Distance = frLct.Distance; toLct.CarSize = frLct.CarSize; toLct.InDate = DateTime.Now; string mss = "数据挪移- 目的车位:" + toLct.Address + " 状态:" + toLct.Status.ToString() + " 卡号:" + toLct.ICCardCode; new CWSException(mss, 0); frLct.Status = CLocation.EnmLocationStatus.Space; frLct.SetICCard(null); frLct.Distance = 0; frLct.CarSize = ""; frLct.InDate = CObject.DefDatetime; string msg = "数据挪移- 源车位:" + frLct.Address + " 状态:" + frLct.Status.ToString() + " 卡号:" + frLct.ICCardCode; new CWSException(msg, 0); CWData.myDB.ManTransportLocation(frLct, toLct); return(100); } else { return(102); //车位不可用 } } else { return(101); } } catch (Exception ex) { HttpRuntime.Cache.Remove("CLocations"); throw ex; } }
public FrmLctTip(CLocation lct) : this() { try { lblAddress.Text = lct.Address; lblSize.Text = lct.Size; if (lct.Type == EnmLocationType.Normal) { if (lct.Status == EnmLocationStatus.Space || lct.Status == EnmLocationStatus.Init) { lblStatus.Text = "空闲"; lblIccode.Text = ""; lblType.Text = ""; lblIndtime.Text = ""; lblCarSize.Text = ""; lblDistance.Text = ""; } else { if (lct.ICCardCode != "") { CICCard iccd = Program.mng.SelectByUserCode(lct.ICCardCode); lblIccode.Text = iccd.Code; string type = ""; if (iccd.Type == EnmICCardType.Temp) { type = "临时卡"; } else if (iccd.Type == EnmICCardType.Fixed) { type = "定期卡"; } else if (iccd.Type == EnmICCardType.FixedLocation) { type = "固定车位卡"; } lblType.Text = type; } else { lblType.Text = ""; lblIccode.Text = ""; } string status = ""; if (lct.Status == EnmLocationStatus.Entering) { status = "正在入库"; } else if (lct.Status == EnmLocationStatus.Outing) { status = "正在出库"; } else if (lct.Status == EnmLocationStatus.Occupy) { status = "占用"; } else if (lct.Status == EnmLocationStatus.Temping) { status = "取物锁定"; } lblStatus.Text = status; lblIndtime.Text = lct.InDate.ToString(); lblCarSize.Text = lct.CarSize; lblDistance.Text = lct.Distance.ToString(); } } else { lblStatus.Text = "不可用"; lblIccode.Text = ""; lblType.Text = ""; lblIndtime.Text = ""; lblCarSize.Text = ""; lblDistance.Text = ""; if (lct.Status != EnmLocationStatus.Space && lct.ICCardCode != "") { CICCard iccd = Program.mng.SelectByUserCode(lct.ICCardCode); lblIccode.Text = iccd.Code; string type = ""; if (iccd.Type == EnmICCardType.Temp) { type = "临时卡"; } else if (iccd.Type == EnmICCardType.Fixed) { type = "定期卡"; } else if (iccd.Type == EnmICCardType.FixedLocation) { type = "固定车位卡"; } lblType.Text = type; lblIndtime.Text = lct.InDate.ToString(); lblCarSize.Text = lct.CarSize; lblDistance.Text = lct.Distance.ToString(); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }