Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox4.Text.Trim() != "" && textBox5.Text.Trim() != "")
            {
                string Start       = dateTimePicker1.Value.ToString("yyyy-MM-dd 00:00:00");
                string Due         = dateTimePicker2.Value.ToString("yyyy-MM-dd 23:59:59");
                string DayInterval = textBox1.Text.Trim();
                string minInterval = textBox2.Text.Trim();
                string RepeatCount = textBox6.Text.Trim();
                string author      = textBox3.Text.Trim();
                string title       = textBox4.Text.Trim();
                string Message     = textBox5.Text.Trim();

                Task.Run(() =>
                {
                    try
                    {
                        string sqlstr = $@"exec [ManagementDB].dbo.[usp_RegisterAnnounce] '0','{SayType}','{SayPosition}','{123}','{Start}','{Due}','{DayInterval}','{minInterval}','{RepeatCount}',N'{author}',N'{title}',N'{Message}'";
                        db._SQL_IDU(sqlstr);
                        this.Invoke(new Action(delegate
                        {
                            MessageBox.Show("操作成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }));
                    }
                    catch (Exception ex)
                    {
                        this.Invoke(new Action(delegate
                        {
                            MessageBox.Show($"发送异常! \r\n{ex.Message}", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }));
                    }
                });
            }
        }
Ejemplo n.º 2
0
        private void  除公告ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int registerID = Convert.ToInt32(listView1.SelectedItems[0].Tag);;

            Task.Run(() =>
            {
                string sqlstr = $@"delete [ManagementDB].dbo.[Announce] where [registerID] = '{registerID}'";
                int count     = db._SQL_IDU(sqlstr);
                this.Invoke(new Action(delegate
                {
                    if (count > 0)
                    {
                        MessageBox.Show("删除成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }));
            });
        }