Пример #1
0
        /// <summary>
        /// 读取记录
        /// </summary>
        /// <returns></returns>
        private bool ReadRecord()
        {
            CHD.API.SYSTEMTIME RecTime     = new CHD.API.SYSTEMTIME();
            byte[]             szRecSource = new byte[10];
            bool nRetFlag = false;
            uint aa = 0, bb = 0;
            int  nRetValue = CHD.API.CHD689.AtReadOneRec(PortId, NetId, szRecSource, ref RecTime, ref aa, ref bb);

            switch (nRetValue)
            {
            case 0x00:                  //Success
                PrintMessage(String.Format("卡号:{0} 时间:{1}", Encoding.Default.GetString(szRecSource), CHD.Common.ParasTime(RecTime)));
                nRetFlag = true;
                break;

            case 0xE4:                  //Failed
                PrintMessage(("设备内无记录!"));
                break;

            case 0xE5:                  //Failed
                PrintMessage(("设备所有记录已经读完!"));
                nRetFlag = false;
                break;

            default:                    //Failed
                PrintMessage(("读取记录失败! 错误代码:" + nRetValue));
                nRetFlag = false;
                break;
            }

            return(nRetFlag);
        }
Пример #2
0
        /// <summary>
        /// 设置就餐时间段
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button26_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            DateTimePicker[] dps = (from Control n in btn.Parent.Controls
                                    where n is DateTimePicker
                                    orderby n.Tag ascending
                                    select(DateTimePicker) n).ToArray();
            CHD.API.SYSTEMTIME[] st = new CHD.API.SYSTEMTIME[16];
            for (int i = 0; i < dps.Length; i++)
            {
                st[i] = CHD.Common.ParasTime(dps[i].Value);
            }
            int nRt = CHD.API.CHD601D_M3.Consume_EatPeriod(PortId, NetId, cmbTimeGroup.SelectedIndex + 1, ref st[0], ref st[1], ref st[2], ref st[3], ref st[4], ref st[5], ref st[6],
                                                           ref st[7], ref st[8], ref st[9], ref st[10], ref st[11], ref st[12], ref st[13], ref st[14], ref st[15]);

            if (nRt == 0)
            {
                PrintMessage("就餐时间段设定成功");
            }
            else
            {
                PrintMessage("就餐时间段设定失败! 错误码: " + nRt);
            }
        }
Пример #3
0
        /// <summary>
        /// Add User
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button28_Click(object sender, EventArgs e)
        {
            if (textBox26.Text.Length != 10)
            {
                MessageBox.Show("Card number input is not correct");
                return;
            }
            if (textBox27.Text.Length != 8)
            {
                MessageBox.Show("User ID input is not correct");
                return;
            }
            if (textBox28.Text.Length != 4)
            {
                MessageBox.Show("Password input is not correct");
                return;
            }
            CHD.API.SYSTEMTIME st = CHD.Common.ParasTime(dateTimePicker9.Value);
            int nRetValue         = CHD.API.CHD825T.CHD825T_AddUser(PortId, NetId, textBox26.Text, textBox27.Text, textBox28.Text, ref st);

            switch (nRetValue)
            {
            case 0x00:
                PrintMessage("Add a user success");
                break;

            default:
                PrintMessage("Add a user failed! error code " + nRetValue);
                break;
            }
        }
Пример #4
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddUser_Click(object sender, EventArgs e)
        {
            byte[] cName = new byte[260];
            byte[] dd    = Encoding.Default.GetBytes(txtUserName.Text);
            for (int i = 0; i < dd.Length; i++)
            {
                cName[i] = dd[i];
            }
            {
                int nLen = dd.Length;
                for (int i = 0; i < nLen; ++i)
                {
                    cName[15 - i * 2]     = ByteToBCD(cName[nLen - i - 1], 1);
                    cName[15 - i * 2 - 1] = ByteToBCD(cName[nLen - i - 1], 2);
                }

                for (int i = 0; i < (15 - nLen * 2 + 1) / 2; i++)
                {
                    cName[i * 2]     = 0x32;
                    cName[i * 2 + 1] = 0x30;
                }
            }

            CHD.API.SYSTEMTIME st = CHD.Common.ParasTime(dpUserLmtDate.Value);
            int nRt = CHD.API.CHD601D_M3.Consume_AddOneUser(PortId, NetId, txtCardNo.Text, txtUserId.Text, txtUserPwd.Text, ref st, cmbUserCardType.SelectedIndex + 1, cName, int.Parse(txtBatch.Text));

            if (nRt == 0)
            {
                PrintMessage("添加用户成功");
            }
            else
            {
                PrintMessage("添加用户失败! 错误码: " + nRt);
            }
        }
Пример #5
0
        /// <summary>
        /// 增加用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button25_Click(object sender, EventArgs e)
        {
            if (textBox27.Text.Length != 10 || textBox28.Text.Length != 8 || textBox29.Text.Length != 4)
            {
                MessageBox.Show("输入信息不正确, 请重新输入");
                return;
            }
            CHD.API.SYSTEMTIME st = CHD.Common.ParasTime(dateTimePicker9.Value);
            int  nItem            = comboBox2.SelectedIndex;
            byte btPrivelege      = 0x00;

            if (nItem == 0)
            {
                btPrivelege = 0xff;
            }
            else
            {
                btPrivelege = 0x00;
            }

            int nRt = CHD.API.CHD815T_M3.CHD815T_M3_AddoneUser(PortId, NetId, textBox27.Text, textBox28.Text, textBox29.Text, ref st, btPrivelege);

            if (nRt == 0)
            {
                PrintMessage("添加一个用户成功");
            }
            else
            {
                PrintMessage("添加一个用户失败! 错误码: " + nRt);
            }
        }
Пример #6
0
        /// <summary>
        /// 分段定值金额设定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button27_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            string[]  cMoney = new string[8];
            TextBox[] txs    = (from Control n in btn.Parent.Controls
                                where n is TextBox
                                orderby n.Tag ascending
                                select(TextBox) n).ToArray();
            for (int i = 0; i < txs.Length; i++)
            {
                if (txs[i].Text.Length == 0)
                {
                    MessageBox.Show("没有输入金额");
                    txs[i].Focus();
                    return;
                }
                cMoney[i] = Convert.ToInt32(txs[i].Text).ToString("X6");
                string[] sTemp = new string[4];
                sTemp[0] = cMoney[i];
                sTemp[1] = sTemp[0].Substring(4, 2);
                sTemp[2] = sTemp[0].Substring(2, 2);
                sTemp[3] = sTemp[0].Substring(0, 2);
                string s = sTemp[1] + sTemp[2] + sTemp[3];
                cMoney[i] = s;
            }


            DateTimePicker[] dps = (from Control n in btn.Parent.Controls
                                    where n is DateTimePicker
                                    orderby n.Tag ascending
                                    select(DateTimePicker) n).ToArray();

            CHD.API.SYSTEMTIME[] st = new CHD.API.SYSTEMTIME[16];
            for (int i = 0; i < dps.Length; i++)
            {
                st[i] = CHD.Common.ParasTime(dps[i].Value);
            }

            int nRt = CHD.API.CHD601D_M3.Consume_SetMoney(PortId, NetId, ref st[0], ref st[1], cMoney[0],
                                                          ref st[2], ref st[3], cMoney[1],
                                                          ref st[4], ref st[5], cMoney[2],
                                                          ref st[6], ref st[7], cMoney[3],
                                                          ref st[8], ref st[9], cMoney[4],
                                                          ref st[10], ref st[11], cMoney[5],
                                                          ref st[12], ref st[13], cMoney[6],
                                                          ref st[14], ref st[15], cMoney[7]);

            if (nRt == 0)
            {
                PrintMessage("分段定值金额设定成功");
            }
            else
            {
                PrintMessage("分段定值金额设定失败! 错误码:" + nRt);
            }
        }
Пример #7
0
        /// <summary>
        /// 设置设备日期
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button21_Click(object sender, EventArgs e)
        {
            CHD.API.SYSTEMTIME time = CHD.Common.ParasTime(DateTime.Now);

            int nRt = CHD.API.CHD815T_M3.CHD815T_M3_SetDateTime(PortId, NetId, ref time);

            if (nRt == 0)
            {
                PrintMessage("设置时间成功");
            }
            else
            {
                PrintMessage("设置时间失败! 错误码: " + nRt);
            }
        }
Пример #8
0
 private CHD.API.SYSTEMTIME ParasTime(DateTime dt)
 {
     if (dt == null)
     {
         dt = DateTime.Now;
     }
     CHD.API.SYSTEMTIME time = new CHD.API.SYSTEMTIME();
     time.wYear         = (ushort)dt.Year;
     time.wMilliseconds = (ushort)dt.Millisecond;
     time.wDay          = (ushort)dt.Day;
     time.wHour         = (ushort)dt.Hour;
     time.wMonth        = (ushort)dt.Month;
     time.wSecond       = (ushort)dt.Second;
     time.wMinute       = (ushort)dt.Minute;
     return(time);
 }
Пример #9
0
        /// <summary>
        /// 同步时间
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSetTime_Click(object sender, EventArgs e)
        {
            CHD.API.SYSTEMTIME stime = CHD.Common.ParasTime(DateTime.Now);

            int nRetValue = CHD.API.CHD689.AtSetDateTime(PortId, NetId, ref stime);

            switch (nRetValue)
            {
            case 0x00:
                PrintMessage(String.Format("同步时间成功:{0} 星期{1}", CHD.Common.ParasTime(stime).ToString(), stime.wDayOfWeek));
                break;

            default:
                PrintMessage("同步时间失败! 错误码: " + nRetValue);
                break;
            }
        }
Пример #10
0
        /// <summary>
        /// Set Date
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSetDate_Click(object sender, EventArgs e)
        {
            CHD.API.SYSTEMTIME stime = CHD.Common.ParasTime(DateTime.Now);


            int nRetValue = CHD.API.CHD825T.CHD825T_SetDateTime(PortId, NetId, ref stime);

            switch (nRetValue)
            {
            case 0x00:
                PrintMessage(String.Format("Synchronization time success:{0} week{1}", CHD.Common.ParasTime(stime).ToString(), stime.wDayOfWeek));
                break;

            default:
                PrintMessage("Synchronization time failed! " + nRetValue);
                break;
            }
        }
Пример #11
0
        /// <summary>
        /// Random Read Record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button32_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox29.Text.Length == 0 || int.Parse(textBox29.Text) > 65535)
                {
                    MessageBox.Show("Loadp wrong");
                    return;
                }
                CHD.API.SYSTEMTIME RecTime = new CHD.API.SYSTEMTIME();
                StringBuilder      szRecSource = new StringBuilder("");
                uint nRecState, nRecRemark;
                int  dd = int.Parse(textBox29.Text);
                int  bRet = 0;
                int  nRetValue = CHD.API.CHD825T.CHD825T_ReadRecByRandom(PortId, NetId, dd, ref bRet, szRecSource, ref RecTime, out nRecState, out nRecRemark);
                switch (nRetValue)
                {
                case 0x00:
                {
                    if (bRet != 0)
                    {
                        PrintMessage(String.Format("success, card:{0}  date:{1}/{2}/{3} {4}:{5}:{6}   state:{7}  remark:{8}", szRecSource, RecTime.wYear, RecTime.wMonth, RecTime.wDay, RecTime.wHour, RecTime.wMinute, RecTime.wSecond, nRecState, nRecRemark));
                        break;
                    }
                    else
                    {
                        PrintMessage(String.Format("success, flag:{0}  addr:{1}  date:{2}/{3} {4]:{5}  no:{6}", szRecSource, nRecState, RecTime.wMonth, RecTime.wDay, RecTime.wHour, RecTime.wMinute, nRecRemark));
                        break;
                    }
                }

                default:
                    PrintMessage("failed! error code " + nRetValue);
                    break;
                }
            }catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
Пример #12
0
        /// <summary>
        /// 增加用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddUser_Click(object sender, EventArgs e)
        {
            CHD.API.SYSTEMTIME time = CHD.Common.ParasTime(dpAddValidDate.Value);
            int nRetValue           = CHD.API.CHD689.AtAddUserWithName(PortId, NetId, txtAddCardNo.Text, txtAddOrder.Text, txtAddUserName.Text, txtAddUserId.Text, null, uint.Parse(txtAddBanCi.Text), ref time);

            switch (nRetValue)
            {
            case 0x00:                  //成功
                PrintMessage(String.Format("增加用户成功! 卡号:{0} 用户ID:{1} 用户名:{2} 用户编号:{3}, 班次:{4}", txtCardNo.Text, txtAddOrder.Text, txtAddUserName.Text, txtAddOrder.Text, txtAddBanCi.Text));
                break;

            case 0x07:                  //SM内已满
                PrintMessage("读取用户信息失败! 错误提示: 无权限!");
                break;

            case 0xE2:                  //SM内已满
                PrintMessage("SM内已满!");
                break;

            case 0xE6:                  //用户ID号重复
                PrintMessage(String.Format("用户ID:{0} 重复!", txtAddOrder.Text));
                break;

            case 0xE7:                  //卡号重复
                PrintMessage(String.Format("卡号:{0} 重复!", txtAddCardNo.Text));
                break;

            case 0xE8:                  //用户信息项全部重复设置
                PrintMessage("用户信息项全部重复设置!");
                break;

            default:                    //其他值表示失败
                PrintMessage(String.Format("增加用户失败! {0}", nRetValue));
                break;
            }
        }
Пример #13
0
 /// <summary>
 /// 设置收费标准
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button43_Click(object sender, EventArgs e)
 {
     try
     {
         int iCarType                          = m_CarType.SelectedIndex + 1;
         int iPerDate_Max_Ceiling              = int.Parse(m_PerDate_Max_Ceiling.Text);
         int iFirstPeriodOfParkingFree         = int.Parse(m_FirstPeriodOfParkingFree.Text);
         int iFirstPeriodOfApply               = int.Parse(m_FirstPeriodOfApply.Text);
         int iFirstPeriodOfApplyStd            = int.Parse(m_FirstPeriodOfApplyStd.Text);
         int iApply_Interval                   = int.Parse(m_Apply_Interval.Text);
         int iInterval_Apply_Std               = int.Parse(m_Interval_Apply_Std.Text);
         CHD.API.SYSTEMTIME stPeakHour_Period1 = CHD.Common.ParasTime(m_PeakHour_Period1.Value);
         CHD.API.SYSTEMTIME stPeakHour_Period2 = CHD.Common.ParasTime(m_PeakHour_Period2.Value);
         int iPeakHour_ParkingFree             = int.Parse(m_PeakHour_ParkingFree.Text);
         int iPeakHour_First                   = int.Parse(m_PeakHour_First.Text);
         int iPeakHour_ApplyStd                = int.Parse(m_PeakHour_ApplyStd.Text);
         int iPeakHour_Interval                = int.Parse(m_PeakHour_Interval.Text);
         int iPeakHour_Interval_ApplyStd       = int.Parse(m_PeakHour_Interval_ApplyStd.Text);
         int iPeakHour_Ceiling                 = int.Parse(m_PeakHour_Ceiling.Text);
         int nRt = CHD.API.CHD815T_M3.CHD815T_M3_SetApplyStd(PortId, NetId, iCarType, iPerDate_Max_Ceiling, iFirstPeriodOfParkingFree,
                                                             iFirstPeriodOfApply, iFirstPeriodOfApplyStd, iApply_Interval, iInterval_Apply_Std, stPeakHour_Period1, stPeakHour_Period2,
                                                             iPeakHour_ParkingFree, iPeakHour_First, iPeakHour_ApplyStd, iPeakHour_Interval, iPeakHour_Interval_ApplyStd, iPeakHour_Ceiling);
         if (nRt == 0)
         {
             PrintMessage("设置收费标准成功");
         }
         else
         {
             PrintMessage("设置收费标准失败! 错误码: " + nRt);
         }
     }
     catch (FormatException)
     {
         MessageBox.Show("请完整的输入收费标准数据!");
     }
 }
Пример #14
0
 /// <summary>
 /// 设置设备日期
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnReadTime_Click(object sender, EventArgs e)
 {
     CHD.API.SYSTEMTIME time = CHD.Common.ParasTime(DateTime.Now);
     PrintExcuteResult(CHD.API.CHD601D_M3.Consume_SetDateTime(PortId, NetId, ref time), "设置时间成功", "设置时间失败!");
 }