Exemplo n.º 1
0
        /// <summary>
        /// 回调方法-配置器当扇区重置返回时
        /// </summary>
        private void SelChsForm_OnChsCleanReponse(uint iCardNo, string strErrInfo)
        {
            if (string.IsNullOrEmpty(strErrInfo))
            {
                try
                {
                    this.Invoke(new EventHandler(delegate
                    {
                        //CMessageBox.ShowSucc(string.Format("恭喜您,扇区重置成功!"), Config.DialogTitle);
                        //字体颜色恢复默认
                        rbList[_rbInt].ForeColor = Color.Black;
                        _ChsCleanList.Remove(_rbInt);
                        btnChsClean.Text = "扇区选择";

                        //删除数据库卡片数据
                        IDAL.ICard objDAL = DALFactory.DALFactory.Card();
                        IList <CardManage.Model.Card> CleanCard = objDAL.GetListByWhere(1, string.Format("cardno = {0}", iCardNo));
                        if (CleanCard.Count > 0 && !objDAL.Delete(CleanCard[0].ID))
                        {
                            CMessageBox.ShowError(string.Format("恭喜您,扇区重置成功,但是删除数据库卡片数据失败!"), Config.DialogTitle);
                            return;
                        }

                        CMessageBox.ShowSucc(string.Format("恭喜您,扇区重置和保存卡片数据到数据库都成功!"), Config.DialogTitle);
                    }));
                }
                catch { }
            }
            else
            {
                CMessageBox.ShowError(string.Format("操作失败,错误原因如下:\r\n{0}", strErrInfo), Config.DialogTitle);
            }
        }
Exemplo n.º 2
0
        private void BtnReadCard_Click(object sender, EventArgs e)
        {
            if (_CurrentAction.Equals(EAction.Edit))
            {
                //修改资料
                this._LastCard = GetCardModel(false, out string strErrMessage);
                if (this._LastCard == null)
                {
                    CMessageBox.ShowError(strErrMessage, Config.DialogTitle);
                    return;
                }

                if (MessageBox.Show("确定要保存修改吗?", Config.DialogTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
                IDAL.ICard objDAL  = DALFactory.DALFactory.Card();
                bool       bIfSucc = objDAL.Update(this._LastCard, out string strErrorInfo);
                if (bIfSucc)
                {
                    CMessageBox.ShowError(string.Format("恭喜您,保存成功!"), Config.DialogTitle);
                }
                else
                {
                    CMessageBox.ShowError(string.Format("保存失败,错误如下:\r\n{0}", strErrorInfo), Config.DialogTitle);
                }
            }
            else
            {
                //读卡
                if (CardConfiger.GetInstance().Switch.Equals(ConfigerBase.ESwitch.CLOSE))
                {
                    if (MessageBox.Show("制卡串口当前已关闭,请先开启后再重试,确定现在开启吗?", Config.DialogTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    CardConfiger.GetInstance().Start(RunVariable.CurrentSetting.WriteComProperty);
                }
                else
                {
                    if (MessageBox.Show("确定现在读卡吗?", Config.DialogTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    if (!CardConfiger.GetInstance().ReadCard(out string strErrMessage))
                    {
                        CMessageBox.ShowError(string.Format("读卡失败,错误如下:\r\n{0}", strErrMessage), Config.DialogTitle);
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="selectedItems">当前选择的行项</param>
        protected override void OnDelete(ListView.SelectedListViewItemCollection selectedItems)
        {
            if (MessageBox.Show(string.Format("确定要删除当前选择的卡片信息吗?"), Config.DialogTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            int iSuccNum  = 0;
            int iFaultNum = 0;

            foreach (ListViewItem selectedItem in selectedItems)
            {
                Card       objModel = (Card)selectedItem.Tag;
                IDAL.ICard objDal   = DALFactory.DALFactory.Card();
                if (objDal.Delete(objModel.ID))
                {
                    iSuccNum++;
                }
                else
                {
                    iFaultNum++;
                }
            }

            if (iSuccNum > 0)
            {
                //重新刷新列表
                BindLVData(0, this.CurrentSqlWhere);
            }

            if (iSuccNum == 0)
            {
                CMessageBox.ShowError("对不起,删除失败!", Config.DialogTitle);
            }
            else if (iFaultNum == 0)
            {
                CMessageBox.ShowSucc("恭喜您,删除成功!", Config.DialogTitle);
            }
            else
            {
                CMessageBox.ShowSucc(string.Format("{0}个删除成功,{1}个删除失败", iSuccNum, iFaultNum), Config.DialogTitle);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 绑定数据到列表
        /// </summary>
        /// <param name="selNum">数据条数</param>
        /// <param name="sqlWhereAndOrderBy">条件</param>
        protected override void BindLVData(int selNum = 0, string sqlWhereAndOrderBy = null)
        {
            this.lvContent.BeginUpdate();
            this.lvContent.Items.Clear();
            try
            {
                if (selNum <= 0)
                {
                    selNum = this.DefaultPageSize;
                }
                if (string.IsNullOrEmpty(sqlWhereAndOrderBy) || sqlWhereAndOrderBy.Equals(""))
                {
                    sqlWhereAndOrderBy = "1=1";
                }
                this.CurrentSqlWhere = sqlWhereAndOrderBy;

                IList <Card> listData = null;
                IDAL.ICard   objDAL   = DALFactory.DALFactory.Card();
                listData = objDAL.GetListByWhere(selNum, sqlWhereAndOrderBy);
                if (!(listData == null || listData.Count <= 0))
                {
                    foreach (Card model in listData)
                    {
                        //序号,50|卡号,80|卡片类型,70|小区编码,60|楼栋编码,60|单元编码,60|房间编码,80|卡片系列号,210|卡片有效期,100|发卡时间,100|持卡者姓名,100|联系电话,100|所在房间,100|所在单元,100|所在楼栋,100|所在小区,120
                        ListViewItem item = new ListViewItem(new string[] { Convert.ToString(lvContent.Items.Count + 1), model.CardNo.ToString(), model.CardTypeDesc, FormatBuildingCode(model.RAreaCode), FormatBuildingCode(model.RBuildCode), FormatBuildingCode(model.RUnitCode), FormatRoomCode(model.RRoomCode), model.SerialNo, Functions.ConvertToNormalTime(model.ExpiryDate).ToString(Config.TimeFormat), Functions.ConvertToNormalTime(model.CreateDate).ToString(Config.TimeFormat), model.Contact, model.Tel,
                                                                            model.RoomName, model.UnitName, model.BuildName, model.AreaName })
                        {
                            Tag  = model,
                            Font = new Font("宋体", 9, FontStyle.Regular)
                        };
                        this.lvContent.Items.Add(item);
                    }
                }
            }
            catch (Exception err)
            {
                CMessageBox.ShowWaring(string.Format("系统错误,错误如下:\r\n{0}!", err.Message), Config.DialogTitle);
            }
            this.lvContent.EndUpdate();
        }
Exemplo n.º 5
0
 /// <summary>
 /// 回调方法-配置器当写卡返回时
 /// </summary>
 private void CardViewForm_OnWriteCardReponse(uint iCardNo, string strErrInfo)
 {
     if (this._LastCard == null)
     {
         return;
     }
     if (iCardNo != uint.MaxValue && string.IsNullOrEmpty(strErrInfo))
     {
         try
         {
             this.Invoke(new EventHandler(delegate
             {
                 txtCardNo.Text        = iCardNo.ToString();
                 this._LastCard.CardNo = iCardNo;
                 //保存数据库
                 IDAL.ICard objDAL = DALFactory.DALFactory.Card();
                 if (!_UpdateFlag)
                 {
                     int iNewID = objDAL.Add(this._LastCard, out string strErrorInfo);
                     if (iNewID <= 0)
                     {
                         CMessageBox.ShowError(string.Format("恭喜您,写卡成功,但是保存卡片数据到数据库失败,错误如下:\r\n{0}!", strErrorInfo), Config.DialogTitle);
                         return;
                     }
                 }
                 else
                 {
                     bool bIfSucc = objDAL.Update(this._LastCard, out string strErrorInfo);
                     if (!bIfSucc)
                     {
                         CMessageBox.ShowError(string.Format("恭喜您,写卡成功,但是保存卡片数据到数据库失败,错误如下:\r\n{0}!", strErrorInfo), Config.DialogTitle);
                         return;
                     }
                 }
                 Manager.GetInstance().CardDataChangeNotice();
                 CMessageBox.ShowSucc(string.Format("恭喜您,写卡和保存卡片数据到数据库都成功!"), Config.DialogTitle);
             }));
         }
Exemplo n.º 6
0
        private void EditInitData()
        {
            IDAL.ICard objDAL   = DALFactory.DALFactory.Card();
            Model.Card objModel = objDAL.GetModel(this._CurrentID);
            if (objModel != null)
            {
                txtCardNo.Text     = objModel.CardNo.ToString();
                txtRAreaCode.Text  = FormatBuildingCode(objModel.RAreaCode);
                txtRBuildCode.Text = FormatBuildingCode(objModel.RBuildCode);
                txtRUnitCode.Text  = FormatBuildingCode(objModel.RUnitCode);
                cbAreaCode.Items.Add(string.Format("{0}|{1:D2}", objModel.AreaName, objModel.RAreaCode));
                cbBuildCode.Items.Add(string.Format("{0}|{1:D2}", objModel.BuildName, objModel.RBuildCode));
                cbUnitCode.Items.Add(string.Format("{0}|{1:D2}", objModel.UnitName, objModel.RUnitCode));
                cbFloorCode.Items.Add(string.Format("{0}|{1:D4}", objModel.RoomName, objModel.RRoomCode));
                cbAreaCode.SelectedIndex  = 0;
                cbBuildCode.SelectedIndex = 0;
                cbUnitCode.SelectedIndex  = 0;
                cbFloorCode.SelectedIndex = 0;

                string strRoomCode = FormatRoomCode(objModel.RRoomCode);
                txtRFloorCode.Text = strRoomCode.Substring(0, 2);
                txtRRoomCode.Text  = strRoomCode.Substring(2, 2);

                txtSerialNo.Text = objModel.SerialNo;

                cbCardType.Items.Add(new Model.ComboBoxItem("请选择卡类型", -1));
                cbCardType.Items.Add(new Model.ComboBoxItem("用户卡", 0));
                cbCardType.Items.Add(new Model.ComboBoxItem("巡更卡", 1));
                cbCardType.Items.Add(new Model.ComboBoxItem("管理卡", 2));
                cbCardType.SelectedIndex = objModel.CardType + 1;

                txtContact.Text = objModel.Contact;
                txtTel.Text     = objModel.Tel;
                txtMemo.Text    = objModel.Memo;

                dtExpiryDate.Value = Functions.ConvertToNormalTime(objModel.ExpiryDate);
                cbEndDate.Visible  = false;

                string strBelongDesc = "未归属";
                if (!objModel.AreaName.Equals(""))
                {
                    strBelongDesc  = "";
                    strBelongDesc += string.Format("{0}", objModel.AreaName);
                    if (!objModel.BuildName.Equals(""))
                    {
                        strBelongDesc += string.Format("=>{0}", objModel.BuildName);
                        if (!objModel.UnitName.Equals(""))
                        {
                            strBelongDesc += string.Format("=>{0}", objModel.UnitName);
                            if (!objModel.RoomName.Equals(""))
                            {
                                strBelongDesc += string.Format("=>{0}", objModel.RoomName);
                            }
                        }
                    }
                }
                txtBelongDesc.Text = strBelongDesc;
            }
            //一些控件设置为不可变,隐藏部分控件
            SetReadOnly();
        }