private void button10_Click(object sender, EventArgs e)
        {
            MessageBoxTimeOut _messageBox = new MessageBoxTimeOut();

            _messageBox.Show("测试", "警告");
        }
Beispiel #2
0
        private void CheckTempe(object source, ElapsedEventArgs e)//定时器回调函数
        {
            ((System.Timers.Timer)source).Enabled = false;


            CPUTempe = 0;

            computer.Open();
            computer.Accept(updateVisitor);
            int i = 0, j = 0;

            for (i = 0; i < computer.Hardware.Length; i++)
            {
                //循环找到HardwareType为cpu
                if ((computer.Hardware[i].HardwareType == HardwareType.CPU) || (computer.Hardware[i].HardwareType == HardwareType.GpuNvidia) || (computer.Hardware[i].HardwareType == HardwareType.GpuAti))   //(computer.Hardware[i].HardwareType == HardwareType.CPU) ||
                {
                    for (j = 0; j < computer.Hardware[i].Sensors.Length; j++)
                    {
                        //找到温度
                        if (computer.Hardware[i].Sensors[j].SensorType == SensorType.Temperature)
                        {
                            if (computer.Hardware[i].Sensors[j].Value.Value > CPUTempe)
                            {
                                CPUTempe = computer.Hardware[i].Sensors[j].Value.Value;
                                TopCore  = computer.Hardware[i].Sensors[j].Name;
                            }
                        }
                    }
                }
            }

            Invoke(
                (MethodInvoker) delegate
                { label3.Text = TopCore + "温度:" + CPUTempe.ToString() + "℃"; });
            if (CPUTempe > Convert.ToDouble(numericUpDown1.Value))
            {
                Console.Beep(350, 2000);
                mb.Show(9000, TopCore + "温度:" + CPUTempe.ToString() + "℃", "警告(窗体9秒后自动关闭...)");
            }

            Wordstr       = ((Int32)CPUTempe).ToString();
            Red_color_F   = Convert.ToInt32(CPUTempe * 15 - 660.0f);
            Green_color_F = Convert.ToInt32(1140.0f - CPUTempe * 15);
            if (Red_color_F > 254)
            {
                Red_color_F = 254;
            }
            if (Red_color_F < 1)
            {
                Red_color_F = 1;
            }
            if (Green_color_F > 254)
            {
                Green_color_F = 254;
            }
            if (Green_color_F < 1)
            {
                Green_color_F = 1;
            }

            /*try
             * {
             *  TextSize = TextRenderer.MeasureText(Wordstr, Myfont);
             *  bTemp = Form1.DrawTextBmp(Wordstr, Myfont, Color.FromArgb(Red_color_F, Green_color_F, 0), TextSize, 0, 0, 0, 0);
             *  bTemp = Form1.ClearWhite(bTemp);
             *  iconHandle = bTemp.GetHicon();
             *  iconTemp = Icon.FromHandle(iconHandle);
             * }
             * catch { } */
            TextSize   = TextRenderer.MeasureText(Wordstr, Myfont);
            bTemp      = Form1.DrawTextBmp(Wordstr, Myfont, Color.FromArgb(Red_color_F, Green_color_F, 0), TextSize, 0, 0, 0, 0);
            bTemp      = Form1.ClearWhite(bTemp);
            iconHandle = bTemp.GetHicon();
            iconTemp   = Icon.FromHandle(iconHandle);
            Invoke(
                (MethodInvoker) delegate
            {
                this.notifyIcon1.Icon = iconTemp;
            });
            DestroyIcon(iconTemp.Handle);
            ((System.Timers.Timer)source).Enabled = true;
        }
Beispiel #3
0
        //购买确定按钮
        private void button2_Click(object sender, EventArgs e)
        {
            MessageBoxTimeOut mb      = new MessageBoxTimeOut();
            Random            ran     = new Random();
            string            orderid = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(1000, 9999).ToString(); //自动生成订单号
            string            paydate = DateTime.Now.ToString("yyyy-MM-dd");

            try
            {
                using (SqlConnection conn = new SqlConnection(AppConst.DbPath))
                {
                    string strsql2 = " ";
                    strsql2 = "insert into order_table([orderID] ,[userID] ,[shopID] ,[orderTotalPrice] ,[shipAddress] ,[payMethod] ,[payDate] ,[tranStatus]) values(@orderID,@userID,@shopID,@orderTotalPrice,@shipAddress,@payMethod,@payDate,@tranStatus)";
                    using (SqlCommand comm = new SqlCommand
                    {
                        CommandText = strsql2,
                        CommandType = CommandType.Text,
                        Connection = conn
                    })
                    {
                        comm.Parameters.AddWithValue("@orderID", orderid);
                        comm.Parameters.AddWithValue("@userID", "201801");
                        comm.Parameters.AddWithValue("@shopID", "1001");
                        comm.Parameters.AddWithValue("@orderTotalPrice", this.SUM);
                        comm.Parameters.AddWithValue("@shipAddress", "广东省湛江市赤坎区");
                        comm.Parameters.AddWithValue("@payMethod", 0);
                        comm.Parameters.AddWithValue("@payDate", paydate);
                        comm.Parameters.AddWithValue("@tranStatus", 1);
                        conn.Open();

                        if (Convert.ToInt32(comm.ExecuteNonQuery()) > 0)
                        {
                            //MessageBox.Show("添加成功");
                            //DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            MessageBox.Show("添加失败!");
                        }
                    }
                }
            }
            catch (SqlException sqlex)
            {
                MessageBox.Show("数据库连接错误,错误源是" + sqlex.Message);
            }
            foreach (var item in WIDS)
            {
                try
                {
                    using (SqlConnection conn = new SqlConnection(AppConst.DbPath))
                    {
                        using (SqlCommand cmd = new SqlCommand($"delete  from [Shopping_Cart] where commID='{item}'", conn))
                        {
                            conn.Open();
                            if (Convert.ToInt32(cmd.ExecuteNonQuery()) > 0)
                            {
                                //MessageBox.Show("删除成功");
                            }
                            else
                            {
                                MessageBox.Show(item);
                            }
                        }
                    }
                }
                catch (SqlException sqlex)
                {
                    MessageBox.Show("数据库连接错误,错误源是" + sqlex.Message);
                }
            }

            mb.Show("支付中.........", "提示");
            MessageBox.Show("支付完成", "success");
            DialogResult = DialogResult.Cancel;
        }