private void Cb_WirelessIdList_DropDown(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = Dbhelper.Db.ToTable <CbDeviceInfo>(" and Iosate=1 ");
         if (dt.Rows.Count == cb_WirelessIdList.Items.Count - 1)
         {
             return;
         }
         DataTable newtable = new DataTable();
         newtable.Columns.AddRange(new DataColumn[] {
             new DataColumn("ID", typeof(long)),
             new DataColumn("Description")
         });
         DataRow dr = newtable.NewRow();
         dr["ID"]          = 0;
         dr["Description"] = "请选择(关闭)";
         newtable.Rows.Add(dr);
         foreach (DataRow item in dt.Rows)
         {
             newtable.Rows.Add(new object[] { item["ID"], "编号" + item["HostNumber"] + " 序列号" + item["WirelessID"] });
         }
         cb_WirelessIdList.DisplayMember = "Description";
         cb_WirelessIdList.ValueMember   = "ID";
         cb_WirelessIdList.DataSource    = newtable;
     }
     catch (Exception ex)
     {
         CustomExceptionHandler.GetExceptionMessage(ex);
         MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #2
0
 private void Cb_LoadTempIc_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         if (cb_LoadTempIc.Checked)
         {
             if (Dal_IcDevicePwd.TempIcDevicePassword == null)
             {
                 CbIcDeviePwd mTempIcPwd = Dbhelper.Db.FirstDefault <CbIcDeviePwd>();
                 if (mTempIcPwd == null)
                 {
                     return;
                 }
                 Dal_IcDevicePwd.TempIcDevicePassword = mTempIcPwd;
             }
             _strTempIcPassword = Dal_IcDevicePwd.TempIcDevicePassword.Pwd;
         }
         else
         {
             _strTempIcPassword = string.Empty;
         }
     }
     catch (Exception ex)
     {
         CustomExceptionHandler.GetExceptionMessage(ex);
         MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #3
0
        private void UpdateSqlContent()
        {
            try
            {
                if (Dal_SysSettings.SystemSettings.Version != Application.ProductVersion)
                {
                    StringBuilder sb = new StringBuilder();

                    sb.Append(@" if not exists( select name from sys.columns where name='VagueQueryNumber' and object_id = ( select object_id from sys.tables where name = 'CBDeviceInfo') )
	alter table CbDeviceInfo add VagueQueryNumber int not null default 0 "    );

                    sb.Append(@" if not exists( select name from sys.columns where name='ExitNumber' and object_id = ( select object_id from sys.tables where name = 'CBTempChargeRecord') )
	alter table CBTempChargeRecord add ExitNumber int not null default 0 "    );

                    Dbhelper.Db.ExecuteNonQuery(sb.ToString());

                    Dal_SysSettings.SystemSettings.Version = Application.ProductVersion;
                    XmlHelper.Update <CbSysSettings>(Dal_SysSettings.SystemSettings);
                }
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
        private bool TestSqlConnection()
        {
            bool   IsCanConnectioned = false;
            string ip        = tb_IpAddress.Text.Trim();
            string loginname = tb_LoginName.Text.Trim();
            string password  = tb_Password.Text.Trim();

            string strTestConnection = string.Format("Data Source = {0},1433;Network Library = DBMSSOCN;Initial Catalog = master;User ID = {1};Password = {2}", ip, loginname, password);
            //string strTestConnection = string.Format("Data Source = .;Initial Catalog = master;User Id = {0};Password = {1};", loginname, password);
            SqlConnection conn = new SqlConnection(strTestConnection);

            try
            {
                conn.Open();
                IsCanConnectioned = true;
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                conn.Close();
            }
            return(IsCanConnectioned);
        }
Beispiel #5
0
 /// <summary>
 /// 端口数据接收
 /// </summary>
 /// <param name="param"></param>
 private void SerialPortDataReceived(ParsingParameter param)
 {
     if (!PortHelper.IsConnection)
     {
         return;
     }
     if (PortHelper.CurrentForm != this)
     {
         return;
     }
     this.Invoke(new EventHandler(delegate
     {
         try
         {
             if (param.FunctionAddress == 66 && param.Command == 221)
             {
                 long result = DataParsing.TemporaryContent(param.DataContent);
                 if (result == 0)
                 {
                     DisplayContent("临时 IC 设备口令设置成功,请保管好口令。", Color.Black);
                     ClearTxt();
                 }
                 else
                 {
                     DisplayContent("临时 IC 设备口令设置失败,请确认设备之间的通信是否正常。");
                 }
             }
         }
         catch (Exception ex)
         {
             CustomExceptionHandler.GetExceptionMessage(ex);
         }
     }));
 }
Beispiel #6
0
        private void Btn_Del_Click(object sender, EventArgs e)
        {
            int          index      = 0;
            CbDeviceInfo deviceinfo = FormComm.GetDataSourceToClass <CbDeviceInfo>(dgv_DeviceInfo, ref index);

            if (MessageBox.Show("确认是否删除设备信息。", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
            {
                try
                {
                    Dbhelper.Db.Del <CbDeviceInfo>(deviceinfo.ID);
                    DataTable dt = dgv_DeviceInfo.DataSource as DataTable;
                    dt.Rows.RemoveAt(index);
                    GetDeviceInfoCount();
                    if (cb_AllSelected.CheckState != CheckState.Unchecked)
                    {
                        cb_AllSelected.CheckState = CheckState.Unchecked;
                        btn_Export.Enabled        = false;
                    }
                }
                catch (Exception ex)
                {
                    CustomExceptionHandler.GetExceptionMessage(ex);
                    MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #7
0
        private void Btn_Enter_Click(object sender, EventArgs e)
        {
            int          devicenumber = Utils.StrToInt(tb_DeviceNumber.Text, 0);
            int          wirelessid   = Utils.StrToInt(tb_WirelessID.Text, 0);
            CbDeviceInfo mDeviceInfo  = new CbDeviceInfo()
            {
                HostNumber        = (int)ud_HostNumber.Value,
                IOSate            = cb_IOSate.SelectedIndex,
                DeviceNumber      = devicenumber,
                DeviceMode        = cb_DeviceMode.SelectedIndex,
                FieldPartition    = cb_FieldPartition.SelectedIndex,
                AntiSubmarineBack = cb_AntiSubmarineBack.SelectedIndex,
                VehicleDetection  = cb_VehicleDetection.SelectedIndex,
                Distance          = cb_Distance.SelectedIndex,
                EquipmentDelay    = cb_EquipmentDelay.SelectedIndex,
                Language          = cb_Language.SelectedIndex,
                IsLikeMachine     = cb_IsLikeMachine.SelectedIndex,
                Frequency         = (int)ud_Frequency.Value,
                WirelessID        = wirelessid,
                VagueQueryNumber  = cb_VagueQueryNumber.SelectedIndex
            };

            try
            {
                mDeviceInfo.ID    = Dbhelper.Db.Insert <CbDeviceInfo>(mDeviceInfo);
                Tag               = mDeviceInfo;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void ExportChargeRecord_Form_Load(object sender, EventArgs e)
 {
     try
     {
         _mDeviceInfos = Dbhelper.Db.ToList <CbDeviceInfo>(" and IOSate = 1 ");
         if (_mDeviceInfos.Count > 1)
         {
             cb_ExitNumber.Visible = true;
             btn_Next.Visible      = true;
             pBar.Visible          = false;
             cb_ExitNumber.Items.Add("请选择");
             foreach (CbDeviceInfo item in _mDeviceInfos)
             {
                 cb_ExitNumber.Items.Add(item.HostNumber);
             }
             cb_ExitNumber.SelectedIndex = 0;
         }
         else
         {
             UpdateExitNumber(0);
             StartExport();
         }
     }
     catch (Exception ex)
     {
         CustomExceptionHandler.GetExceptionMessage(ex);
         MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #9
0
        /// <summary>
        /// 窗体加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DistanceDelay_Form_Load(object sender, EventArgs e)
        {
            //初始化端口接收事件
            PortHelper.DataReceived += SerialPortDataReceived;
            //初始化端口变化事件
            PortHelper.ConnectionChange += DeviceConnectionChange;
            PortHelper.CurrentForm       = this;
            try
            {
                //获取副卡集合
                DataTable dt = Dbhelper.Db.ToTable <CbAssociateCard>(" and  CardID=" + _mCardInfo.ID + " ");
                dgv_DataList.DataSource = dt;
                dgv_DataList.Focus();

                if (_mCardInfo.ParkingRestrictions == 1)
                {
                    cb_AllSelected.Checked = true;
                    cb_AllSelected.Enabled = false;
                    dgv_DataList.Enabled   = false;
                    l_Message.Visible      = true;
                }
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #10
0
        /// <summary>
        /// 解锁
        /// </summary>
        /// <param name="cardnumber"></param>
        /// <param name="flag"></param>
        private void UnlockDistanceCard(int flag)
        {
            try
            {
                StopTimeOutThread();
                int index = -1;
                foreach (KeyValuePair <CbCardInfo, int> item in _mUnLockList)
                {
                    index++;
                    if (_mUnLockCardInfo != null && item.Key == _mUnLockCardInfo)
                    {
                        if (flag == 0)
                        {
                            item.Key.Unlocked = 0;
                            Dbhelper.Db.Update <CbCardInfo>(item.Key);
                            dgv_UnlockList["c_State", index].Value = Properties.Resources.check;
                            OnLockChange(item);
                        }
                        _mUnLockCardInfo = null;
                        continue;
                    }
                    if (_mUnLockCardInfo != null)
                    {
                        continue;
                    }
                    if (item.Key.Unlocked == 0)
                    {
                        continue;
                    }
                    _mUnLockCardInfo = item.Key;
                    DistanceTypeParameter typeparam = new DistanceTypeParameter()
                    {
                        Lock = 0, Distance = item.Key.Distance
                    };
                    int    typebyte = DistanceCardHelper.SetCardTypeByte(typeparam, 1);
                    byte[] by       = PortAgreement.GetDistanceContent(item.Key.CardNumber, typebyte);
                    PortHelper.SerialPortWrite(by);

                    StartTimeOutThread();
                    return;
                }
                foreach (KeyValuePair <CbCardInfo, int> item in _mUnLockList)
                {
                    if (item.Key.Unlocked != 0)
                    {
                        UseControlEnabled();
                        return;
                    }
                }
                dgv_UnlockList.Rows.Clear();
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                UseControlEnabled();
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #11
0
        private void Btn_Delete_Click(object sender, EventArgs e)
        {
            DateTime now = DateTime.Now;

            switch (cb_TimeSlot.SelectedIndex)
            {
            case 1:
                now = now.AddMonths(-1);
                break;

            case 2:
                now = now.AddMonths(-3);
                break;

            case 3:
                now = now.AddMonths(-6);
                break;

            case 4:
                now = now.AddMonths(-12);
                break;
            }
            try
            {
                btn_Delete.Enabled = false;

                StringBuilder sb = new StringBuilder();
                if (cb_EnterExitRecord.Checked)
                {
                    Dbhelper.Db.Del <CbIoRecord>(string.Format(" and IOTime < '{0:yyyy-MM-dd}' ", now));
                    sb.Append("  Vacuum CbIoRecord ; ");
                }
                if (cb_ChargeReocrd.Checked)
                {
                    Dbhelper.Db.Del <CbTempChargeRecord>(string.Format(" and ExportTime < '{0:yyyy-MM-dd}' ", now));
                    sb.Append("  Vacuum CbTempChargeRecord ; ");
                }
                if (cb_DelayRecord.Checked)
                {
                    Dbhelper.Db.Del <CbLprDelayRecord>(string.Format(" and RecordTime < '{0:yyyy-MM-dd}' ", now));
                    sb.Append("  Vacuum CbLprDelayRecord ; ");
                }
                //Dbhelper.Db.Del<CbManageLog>(string.Format(" and LogTime < '{0:yyyy-MM-dd}' ", now));

                if (Dal_SysSettings.SystemSettings.RemoteConnection == 0)
                {
                    //sb.Append(" Vacuum CbManageLog ");
                    Dbhelper.Db.ExecuteNonQuery(sb.ToString());
                }
                btn_Delete.Enabled = true;
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                btn_Delete.Enabled = true;
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #12
0
        private void Btn_Enter_Click(object sender, EventArgs e)
        {
            try
            {
                int    chargemode  = cb_ChargeMode.SelectedIndex;
                int    openmode    = cb_OpenMode.SelectedIndex;
                int    freeminutes = (int)ud_FreeMinutes.Value;
                double dailylimit  = (double)ud_DailyLimit.Value;
                int    firstcharge = (int)ud_FirstCharge.Value;
                double firstmoney  = (double)ud_FirstMoney.Value;
                int    twocharge   = (int)ud_TwoCharge.Value;
                double twomoney    = (double)ud_TwoMoney.Value;
                int    threecharge = (int)ud_ThreeCharge.Value;
                double threemoney  = (double)ud_ThreeMoney.Value;
                int    fourcharge  = (int)ud_FourCharge.Value;
                double fourmoney   = (double)ud_FourMoney.Value;
                int    fivecharge  = (int)ud_FiveCharge.Value;
                double fivemoney   = (double)ud_FiveMoney.Value;
                int    sixcharge   = (int)ud_SixCharge.Value;
                double sixmoney    = (double)ud_SixMoney.Value;

                _mChargeParam.ChargeMode  = chargemode;
                _mChargeParam.GateMode    = openmode;
                _mChargeParam.FreeMinutes = freeminutes;
                _mChargeParam.DailyLimit  = dailylimit;
                _mChargeParam.FirstCharge = firstcharge;
                _mChargeParam.FirstMoney  = firstmoney;
                _mChargeParam.TwoCharge   = twocharge;
                _mChargeParam.TwoMoney    = twomoney;
                _mChargeParam.ThreeCharge = threecharge;
                _mChargeParam.ThreeMoney  = threemoney;
                _mChargeParam.FourCharge  = fourcharge;
                _mChargeParam.FourMoney   = fourmoney;
                _mChargeParam.FiveCharge  = fivecharge;
                _mChargeParam.FiveMoney   = fivemoney;
                _mChargeParam.SixCharge   = sixcharge;
                _mChargeParam.SixMoney    = sixmoney;

                if (_mChargeParam.ID == 0)
                {
                    _mChargeParam.ID = Dbhelper.Db.Insert <CbChargeParameter>(_mChargeParam);
                }
                else
                {
                    Dbhelper.Db.Update <CbChargeParameter>(_mChargeParam);
                }
                Dal_ChargeParameter.ChargeParam = _mChargeParam;
                _mChargeParam = null;
                MessageBox.Show("收费标准保存成功。", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, @"提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #13
0
        private void Btn_Enter_Click(object sender, EventArgs e)
        {
            string username    = tb_UserName.Text.Trim();
            string platenumber = tb_PlateNumber.Text.Trim();
            int    sex         = cb_Sex.SelectedIndex;
            int    age         = (int)ud_Age.Value;
            string phone       = tb_Phone.Text.Trim();
            string address     = tb_Address.Text.Trim();

            if (username.Length == 0)
            {
                //l_UserNameTitle.Text = "用户名称不能为空";
                //l_UserNameTitle.ForeColor = Color.Red;
                tb_UserName.Focus();
                return;
            }
            //if (platenumber.Length == 0)
            //{
            //    l_PlateNumberTitle.Text = "车牌号码不能为空";
            //    l_PlateNumberTitle.ForeColor = Color.Red;
            //    tb_PlateNumber.Focus();
            //    return;
            //}
            //if (phone.Length == 0)
            //{
            //    l_PhoneTitle.Text = "电话号码不能为空";
            //    l_PhoneTitle.ForeColor = Color.Red;
            //    tb_Phone.Focus();
            //    return;
            //}
            CbCardInfo mCardInfo = new CbCardInfo()
            {
                UserName         = username,
                PlateNumber      = platenumber,
                UserSex          = sex,
                UserAge          = age,
                UserPhone        = phone,
                UserAddress      = address,
                CardNumber       = string.Empty,
                StartTime        = DateTime.Now,
                StopTime         = DateTime.Now,
                RegistrationTime = DateTime.Now
            };

            try
            {
                mCardInfo.ID      = Dbhelper.Db.Insert <CbCardInfo>(mCardInfo);
                this.Tag          = mCardInfo;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Search_Click(object sender, EventArgs e)
        {
            string content = tb_SearchContent.Text.Trim();

            if (content.Length > 0)
            {
                try
                {
                    _isAddRow = true;
                    if (Tab3_Form.SubList != null && Tab3_Form.SubList.Count > 0)
                    {
                        //移除旧的搜索副卡内容
                        for (int i = dgv_ViceCardList.RowCount - 1; i >= Tab3_Form.SubList.Count; i--)
                        {
                            dgv_ViceCardList.Rows.RemoveAt(i);
                        }
                    }
                    else
                    {
                        dgv_ViceCardList.Rows.Clear();
                    }
                    //获取搜索的副卡
                    DataTable dt = Dal_AssociateCard.GetViceCard(content);
                    if (dt.Rows.Count > 0)
                    {
                        //将副卡显示在列表中
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            object vicecardnumber = dt.Rows[i]["ViceCardNumber"];
                            if (Tab3_Form.SubList != null && Tab3_Form.SubList.Count > 0)
                            {
                                if (Tab3_Form.SubList.ContainsKey(vicecardnumber.ToString()))
                                {
                                    continue;
                                }
                            }
                            //验证当前副卡是否已经存在捆绑列表中
                            bool check = GetViceCardExists(vicecardnumber.ToString());
                            dgv_ViceCardList.Rows.Add(new object[] { check, vicecardnumber, string.Empty });
                        }
                    }
                }
                catch (Exception ex)
                {
                    CustomExceptionHandler.GetExceptionMessage(ex);
                    MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    _isAddRow = false;
                }
            }
        }
Beispiel #15
0
        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Enter_Click(object sender, EventArgs e)
        {
            //获取延期时间
            DateTime newtime = t_NewTime.Value;
            //获取车场分区的值
            int partition = cb_CardPartition.SelectedIndex == 0 ? 0 : GetPartition();

            if (_mCardInfo != null)//定距卡
            {
                btn_Enter.Enabled         = false;
                _mCardInfo.StopTime       = newtime;
                _mCardInfo.FieldPartition = partition;

                try
                {
                    if (_mCardCounting == null)
                    {
                        //获取定距卡计数信息
                        _mCardCounting = Dbhelper.Db.FirstDefault <CbCardCountingState>(" and UseNumber = '" + _mCardInfo.CardNumber + "' ");
                        //计数加1
                        _mCardCounting.UseCounting = DistanceCardHelper.LimitCount(_mCardCounting.UseCounting);
                    }
                    //将数据写入定距卡
                    byte[] by = DistanceCardHelper.SetDistanceData(_mCardInfo.CardNumber, _mCardCounting.UseCounting, _mCardInfo.StopTime, _mCardInfo.FieldPartition);
                    PortHelper.SerialPortWrite(by);
                    StartTimeOut();
                }
                catch (Exception ex)
                {
                    btn_Enter.Enabled = true;
                    CustomExceptionHandler.GetExceptionMessage(ex);
                    MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (_mAssociateCard != null)//单张副卡
            {
                _mAssociateCard.UpdateTime      = newtime;
                _mAssociateCard.SubCardDivision = partition;
                this.Tag          = _mAssociateCard;
                this.DialogResult = DialogResult.OK;
            }
            else //批量延期
            {
                foreach (CbAssociateCard item in _mAssociateCards)
                {
                    item.UpdateTime      = newtime;
                    item.SubCardDivision = partition;
                }
                this.Tag          = _mAssociateCards;
                this.DialogResult = DialogResult.OK;
            }
        }
 /// <summary>
 /// 端口数据接收
 /// </summary>
 /// <param name="param"></param>
 private void SerialPortDataReceived(ParsingParameter param)
 {
     if (!PortHelper.IsConnection)
     {
         return;
     }
     if (PortHelper.CurrentForm != this)
     {
         return;
     }
     this.Invoke(new EventHandler(delegate
     {
         if (tb_NewPwd.TextLength == 0)
         {
             return;
         }
         try
         {
             if (param.FunctionAddress == 65)
             {
                 DistanceParameter distanceparam = DataParsing.DistanceParsingContent(param.DataContent);
                 if (distanceparam.Command == 160)
                 {
                     if (distanceparam.AuxiliaryCommand == 0)//成功
                     {
                         DisplayContent("多功能操作平台口令设置成功,请保管好口令。", Color.Black);
                         ClearTxt();
                     }
                     else//失败
                     {
                         DisplayContent("多功能操作平台口令设置失败,请重新操作。");
                     }
                 }
                 else
                 {
                     DisplayContent("未知数据内容。");
                 }
             }
             else
             {
                 DisplayContent("未知数据内容。");
             }
         }
         catch (Exception ex)
         {
             CustomExceptionHandler.GetExceptionMessage(ex);
             MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }));
 }
 private void GetRecordCount()
 {
     try
     {
         string strwhere = GetSearchWhere();
         int    count    = Dbhelper.Db.GetCount <CbCardInfo>("ID", strwhere);
         PageCount   = FormComm.GetPage(count, 30, l_PageTile);
         CurrentPage = 1;
     }
     catch (Exception ex)
     {
         CustomExceptionHandler.GetExceptionMessage(ex);
         MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #18
0
 private void GetManageInfo()
 {
     try
     {
         DataTable dt = Dal_ManageInfo.GetManageAndRights();
         dt.Columns.Remove("ID1");
         dt.Columns.Remove("UserID");
         dgv_ManageList.DataSource = dt;
         dgv_ManageList.Focus();
     }
     catch (Exception ex)
     {
         CustomExceptionHandler.GetExceptionMessage(ex);
         MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void Btn_Next_Click(object sender, EventArgs e)
 {
     try
     {
         UpdateExitNumber(cb_ExitNumber.SelectedIndex - 1);
         cb_ExitNumber.Visible = false;
         btn_Next.Visible      = false;
         pBar.Visible          = true;
         StartExport();
     }
     catch (Exception ex)
     {
         CustomExceptionHandler.GetExceptionMessage(ex);
         MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #20
0
        private void Btn_Enter_Click(object sender, EventArgs e)
        {
            string account = tb_Accounts.Text.Trim();
            string name    = tb_Name.Text.Trim();
            int    index   = cb_ManageType.SelectedIndex + 1;

            if (account.Length == 0)
            {
                //l_AccountsTitle.Text = "帐号不能为空";
                l_AccountsTitle.ForeColor = Color.Red;
                tb_Accounts.Focus();
                return;
            }
            //if (account.Length < 6)
            //{
            //    MessageBox.Show("帐号长度不能小于 6 位,请重新输入。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    tb_Accounts.Focus();
            //    tb_Accounts.SelectionStart = tb_Accounts.TextLength;
            //    return;
            //}
            if (name.Length == 0)
            {
                //l_NameTitle.Text = "用户名称不能为空";
                l_NameTitle.ForeColor = Color.Red;
                tb_Name.Focus();
                return;
            }

            try
            {
                _mManageInfo.UserName   = name;
                _mManageInfo.ManageType = index;
                Dbhelper.Db.Update <CbManageInfo>(_mManageInfo);
                if (_mManageInfo.ID == Dal_ManageInfo.ManageInfo.ID)
                {
                    Dal_ManageInfo.ManageInfo = _mManageInfo;
                }
                this.Tag          = _mManageInfo;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #21
0
 private void GetRecordCount()
 {
     try
     {
         string where = GetSearchWhere();
         DataTable dt = Dbhelper.Db.GetAggregate <CbTempChargeRecord>(new AggregateFuncion[] {
             new AggregateFuncion()
             {
                 AggregateType = AggregateTypes.COUNT, Column = "ID", ColumnAlias = "RecordCount"
             },
             new AggregateFuncion()
             {
                 AggregateType = AggregateTypes.SUM, Column = "ChargeAmount", ColumnAlias = "Charges"
             },
             new AggregateFuncion()
             {
                 AggregateType = AggregateTypes.SUM, Column = "ActualAmount", ColumnAlias = "PaidInAmount"
             },
         }, where);
         int    count = 0;
         double charges = 0, paidinamount = 0;
         object obj = dt.Rows[0]["RecordCount"];
         if (obj != DBNull.Value)
         {
             count = Convert.ToInt32(obj);
         }
         obj = dt.Rows[0]["Charges"];
         if (obj != DBNull.Value)
         {
             charges = Convert.ToDouble(obj);
         }
         obj = dt.Rows[0]["PaidInAmount"];
         if (obj != DBNull.Value)
         {
             paidinamount = Convert.ToDouble(obj);
         }
         l_StatisticsAll.Text = string.Format("总计金额    应收:{0}元      实收:{1}元", charges, paidinamount);
         PageCount            = FormComm.GetPage(count, 30, l_PageTitle);
         CurrentPage          = 1;
     }
     catch (Exception ex)
     {
         CustomExceptionHandler.GetExceptionMessage(ex);
         MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #22
0
        private void UpdateSqliteContent()
        {
            try
            {
                if (Dal_SysSettings.SystemSettings.Version != Application.ProductVersion)
                {
                    StringBuilder sb = new StringBuilder();

                    string    cmdtext = " select sql from sqlite_master where name='CBDeviceInfo' ";
                    DataTable dt      = Dbhelper.Db.ToTable(cmdtext);
                    if (dt.Rows.Count > 0)
                    {
                        string sql = dt.Rows[0]["sql"].ToString();
                        if (!sql.Contains("VagueQueryNumber"))
                        {
                            sb.Append(" alter table CBDeviceInfo add column VagueQueryNumber INT default(0) ; ");
                        }
                    }

                    cmdtext = " select sql from sqlite_master where name='CBTempChargeRecord' ";
                    dt      = Dbhelper.Db.ToTable(cmdtext);
                    if (dt.Rows.Count > 0)
                    {
                        string sql = dt.Rows[0]["sql"].ToString();
                        if (!sql.Contains("ExitNumber"))
                        {
                            sb.Append(" alter table CBTempChargeRecord add column ExitNumber Int Default(0) ; ");
                        }
                    }

                    if (sb.Length > 0)
                    {
                        Dbhelper.Db.ExecuteNonQuery(sb.ToString());
                    }

                    Dal_SysSettings.SystemSettings.Version = Application.ProductVersion;
                    XmlHelper.Update <CbSysSettings>(Dal_SysSettings.SystemSettings);
                }
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #23
0
        private void Btn_Backups_Click(object sender, EventArgs e)
        {
            string backupsdirectory = tb_BackupsAddress.Text.Trim();

            if (backupsdirectory.Length == 0)
            {
                FolderBrowserDialog folder = new FolderBrowserDialog();
                if (folder.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                backupsdirectory = folder.SelectedPath;
            }
            if (!Directory.Exists(backupsdirectory))
            {
                MessageBox.Show("目录不存在,请重新选择目录。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string backupsaddress = string.Format(@"{0}\{1}.db", backupsdirectory, DateTime.Now.ToString("yyyyMMddHHmmssff"));

            try
            {
                btn_Backups.Enabled = false;

                //FileHelper.CopyFile(fileaddress, newfileaddress);
                Dbhelper.Backups(backupsaddress);

                Thread tDelayShowBtn = new Thread(DelayShowBackupsBtn);
                tDelayShowBtn.IsBackground = true;
                tDelayShowBtn.Start();

                if (backupsdirectory != Dal_SysSettings.SystemSettings.BackupsAddress)
                {
                    Dal_SysSettings.SystemSettings.BackupsAddress = backupsdirectory;
                    XmlHelper.Update <CbSysSettings>(Dal_SysSettings.SystemSettings);
                }
                MessageBox.Show("数据库备份完成。", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                btn_Backups.Enabled = true;
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #24
0
        private void Btn_Enter_Click(object sender, EventArgs e)
        {
            string account  = tb_Accounts.Text.Trim();
            string password = tb_Password.Text.Trim();

            if (account.Length == 0)
            {
                l_AccountsTitle.Text      = "帐号不能为空";
                l_AccountsTitle.ForeColor = Color.Red;
                tb_Accounts.Focus();
                return;
            }
            //if (password.Length == 0)
            //{
            //    l_PasswordTitle.Text = "密码不能为空";
            //    l_PasswordTitle.ForeColor = Color.Red;
            //    tb_Password.Focus();
            //    return;
            //}
            try
            {
                CbManageInfo Manage = Dal_ManageInfo.GetManage(account, password);
                if (Manage == null)
                {
                    MessageBox.Show("帐号或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (account != Dal_SysSettings.SystemSettings.ManageAccount || cb_RecordPassword.Checked != Dal_SysSettings.SystemSettings.IsSavePassword || password != Dal_SysSettings.SystemSettings.ManagePassword)
                {
                    Dal_SysSettings.SystemSettings.ManageAccount  = account;
                    Dal_SysSettings.SystemSettings.IsSavePassword = cb_RecordPassword.Checked;
                    Dal_SysSettings.SystemSettings.ManagePassword = password;
                    XmlHelper.Update <CbSysSettings>(Dal_SysSettings.SystemSettings);
                }
                Dal_ManageInfo.ManageInfo     = Manage;
                Dal_ManageRights.ManageRights = Dbhelper.Db.FirstDefault <CbManageRights>(" and UserId=" + Manage.ID);
                this.DialogResult             = DialogResult.OK;
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// 连接
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_ModuleConnection_Click(object sender, EventArgs e)
        {
            btn_ModuleConnection.Enabled = false;

            try
            {
                if (ud_WirelessId.Value == 0)
                {
                    //保存频道和ID
                    SaveWirelessParameter();
                    MessageBox.Show("搜索主机关闭成功。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                using (SearchWirelessFrequency_Form search = new SearchWirelessFrequency_Form((int)ud_WirelessId.Value, (int)ud_WirelessFrequency.Value))
                {
                    if (search.ShowDialog() == DialogResult.OK)
                    {
                        int frequency = Utils.ObjToInt(search.Tag, 1);
                        ud_WirelessFrequency.Value = frequency;
                        //保存频道和ID
                        SaveWirelessParameter();
                        l_ModuleConnectionState.Text             = "已连接";
                        l_ModuleConnectionState.ForeColor        = Color.Green;
                        Tab4_Form.GetInstance.IsConnectionModule = true;
                    }
                    else
                    {
                        l_ModuleConnectionState.Text             = "未连接";
                        l_ModuleConnectionState.ForeColor        = Color.Red;
                        Tab4_Form.GetInstance.IsConnectionModule = false;
                    }
                }
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                btn_ModuleConnection.Enabled = true;
            }
        }
Beispiel #26
0
 /// <summary>
 /// 端口数据接收事件
 /// </summary>
 /// <param name="param"></param>
 private void SerialPortDataReceived(ParsingParameter param)
 {
     if (!PortHelper.IsConnection)
     {
         return;
     }
     if (PortHelper.CurrentForm != this)
     {
         return;
     }
     try
     {
         if (param.FunctionAddress == 65)
         {
             StopTimeOut();
             //解析数据内容
             DistanceParameter distanceparam = DataParsing.DistanceParsingContent(param.DataContent);
             if (distanceparam.Command == 27)             //定距卡写入
             {
                 if (distanceparam.AuxiliaryCommand == 0) //成功
                 {
                     Dbhelper.Db.Update <CbCardInfo>(_mCardInfo);
                     Dbhelper.Db.Update <CbCardCountingState>(_mCardCounting);
                     this.Tag          = _mCardInfo;
                     this.DialogResult = DialogResult.OK;
                 }
                 else
                 {
                     MessageBox.Show("定距卡写入失败,请将定距卡放置在发行器可读写区域内,重新操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         CustomExceptionHandler.GetExceptionMessage(ex);
         MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         btn_Enter.Enabled = true;
     }
 }
        private void Btn_SerialPortConnection_Click(object sender, EventArgs e)
        {
            Tab4_Form.GetInstance.IsReadIcCard = false;
            if (PortHelper.sp.IsOpen)
            {
                try
                {
                    PortHelper.sp.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                SerialPortChange(PortHelper.IsConnection);
            }
            else
            {
                PortHelper.sp.PortName = cb_SerialPortName.SelectedItem.ToString();
                try
                {
                    PortHelper.sp.Open();

                    PortHelper.SerialPortWrite(PortAgreement.GetDistanceEncryption(Dal_DevicePwd.DistanceSystemPassword.Pwd));

                    Thread.Sleep(600);

                    if (!PortHelper.IsConnection)
                    {
                        PortHelper.sp.Close();
                        MessageBox.Show("当前端口连接失败,请选择正确的端口进行连接。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        SerialPortChange(PortHelper.IsConnection);
                    }
                }
                catch (Exception ex)
                {
                    CustomExceptionHandler.GetExceptionMessage(ex);
                    MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
 private void ExportRecord()
 {
     try
     {
         string       savepath = string.Format("{0}\\出口{1}收费记录.xls", _ExportFileAddress, _mDeviceInfo.HostNumber);
         DataTable    dt       = Dbhelper.Db.ToTable <CbTempChargeRecord>(_strWhere);
         ExcelHandler excel    = new ExcelHandler();
         excel.RenderDataTableToExcel(dt, "收费记录", savepath);
     }
     catch (Exception ex)
     {
         CustomExceptionHandler.GetExceptionMessage(ex);
         MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         tExportRecord = null;
         Close();
     }
 }
        private void Btn_Del_Click(object sender, EventArgs e)
        {
            int        index     = 0;
            CbCardInfo mCardInfo = FormComm.GetDataSourceToClass <CbCardInfo>(dgv_InfoList, ref index);

            if (MessageBox.Show("确认删除用户:" + mCardInfo.UserName + " 的信息吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) != DialogResult.OK)
            {
                return;
            }
            try
            {
                Dbhelper.Db.Del <CbCardInfo>(mCardInfo.ID);
                GetRecordCount();
                //DataTable dt = dgv_InfoList.DataSource as DataTable;
                //dt.Rows.RemoveAt(index);
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void Cb_WirelessIdList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cb_WirelessIdList.SelectedIndex > 0)
     {
         try
         {
             CbDeviceInfo mDeviceInfo = Dbhelper.Db.FirstDefault <CbDeviceInfo>((long)cb_WirelessIdList.SelectedValue);
             ud_WirelessId.Value        = mDeviceInfo.IsLikeMachine == 0 ? mDeviceInfo.HostNumber : mDeviceInfo.WirelessID;
             ud_WirelessFrequency.Value = mDeviceInfo.HostNumber > 64 ? mDeviceInfo.HostNumber - 64 : mDeviceInfo.HostNumber;
         }
         catch (Exception ex)
         {
             CustomExceptionHandler.GetExceptionMessage(ex);
             MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         ud_WirelessFrequency.Value = 1;
         ud_WirelessId.Value        = 0;
     }
 }