Beispiel #1
0
        private bool PERFORM_ADD()
        {
            try
            {
                bool Result = false;

                string sql = "INSERT INTO IT_WORKSTATIONS.TICKETS_NEW (DATE_FILED, REQUESTEE, DESCRIPTION, TICKETS_NEW.STATUS) " +
                             "VALUES(@Date_Filed, @Requestee, @Description, @Status);";
                string ConnStr = Pub.Decrypt(System.IO.File.ReadAllText("connectionstring.itis"), Pub.passphraselesky);

                MySqlConnection Conn = new MySqlConnection(ConnStr);
                Conn.Open();
                if (Conn.State != System.Data.ConnectionState.Open)
                {
                    throw new Exception("MySQL Connection is not open.");
                }

                using (MySqlCommand cmd = new MySqlCommand(sql, Conn))
                {
                    cmd.Parameters.AddWithValue("@Date_Filed", DateTime.Today.ToString("yyyy-MM-dd"));

                    string Requestee = Pub.isIT_Support() ?
                                       ((CboRequestee.SelectedItem != null) ? (CboRequestee.SelectedItem as ComboBoxItem).Content.ToString() : CboRequestee.Text) :
                                       Pub.MyDisplayName();

                    cmd.Parameters.AddWithValue("@Requestee", Requestee);
                    cmd.Parameters.AddWithValue("@Description", TxtRemarks.Text);
                    cmd.Parameters.AddWithValue("@Status", "OPEN");

                    int x = cmd.ExecuteNonQuery();

                    Result = x > 0;

                    cmd.Dispose();
                    Conn.Close();
                }

                return(Result);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #2
0
        public string ReadCard()
        {
            string port   = SkyComm.getvalue("读卡器Port");
            IntPtr hadler = Init(Convert.ToInt32(port));

            if (hadler.ToInt32() == 0)
            {
                MyMsg.MsgInfo("端口打开失败!");
                return(string.Empty);
            }

            try
            {
                int i = M100IC_DLL.M100_EnterCard(hadler, 0x30, 15000);
                if (i != 0)
                {
                    MyMsg.MsgInfo("进卡失败");
                    return(string.Empty);
                }

                i = M100IC_DLL.M100_MoveCard(hadler, 0x31);
                if (i != 0)
                {
                    MyMsg.MsgInfo("卡片传动IC卡位失败");
                    return(string.Empty);
                }

                i = M100IC_DLL.M100_IcCardPowerOn(hadler);
                if (i != 0)
                {
                    MyMsg.MsgInfo("上电失败");
                    return(string.Empty);
                }

                byte[] buf = new byte[3];
                buf[0] = Convert.ToByte("FF", 16);
                buf[1] = Convert.ToByte("FF", 16);
                buf[2] = Convert.ToByte("FF", 16);
                i      = M100IC_DLL.M100_SLE4442VerifyPWD(hadler, buf);
                if (i != 0)
                {
                    MyMsg.MsgInfo("密码验证失败");
                    return(string.Empty);
                }

                byte[] _data = new byte[88];
                i = M100IC_DLL.M100_SLE4442Read(hadler, 27, 88, _data);
                if (i != 0)
                {
                    MyMsg.MsgInfo("读卡失败");
                    return(string.Empty);
                }

                i = M100IC_DLL.M100_IcCardPowerOff(hadler);
                if (i != 0)
                {
                    MyMsg.MsgInfo("下电失败");
                    return(string.Empty);
                }

                i = M100IC_DLL.M100_MoveCard(hadler, 0x32);
                if (i != 0)
                {
                    MyMsg.MsgInfo("退卡失败");
                    return(string.Empty);
                }

                string cardNo = string.Empty;

                try
                {
                    string msg       = Encoding.ASCII.GetString(_data);
                    string returnstr = Pub.Decrypt(msg, "SOFT-HIS");
                    cardNo = returnstr;
                }
                catch
                {
                    MyMsg.MsgInfo("卡片数据错误!或卡插入方向不正确");
                    return(string.Empty);
                }

                return(cardNo);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                ClosePort(hadler);
            }
        }