我正在编写一个程序来创建一个系统托盘来弹出消息。 在程序中,我检查它是否是有效用户,然后将显示通知
否则
不会显示任何通知消息。
但如果用户(用户代码)没有会议,则会出现空白通知消息弹出窗口。
我想隐藏通知消息。
请帮帮我。
我已经编写了代码
using (SqlConnection CNN = new SqlConnection(AppManager.GetConnectionString()))
{
CNN.Open();
//getting all records from Meeting
using (SqlCommand scmd = new SqlCommand())
{
using (DataTable dtMeeting = new DataTable())
{
scmd.CommandText = "SELECT MeetingNumber from Meeting";
scmd.Connection = CNN;
SqlDataAdapter sdaMeeting = new SqlDataAdapter(scmd);
sdaMeeting.Fill(dtMeeting);
foreach (DataRow drMeeting in dtMeeting.Rows)
{
using (DataTable dtAttendies = new DataTable())
{
scmd.CommandText = "SELECT MEETING.MeetingNumber, MEETING.MeetingType," +
" MEETINGTYPEMASTER.MeetingTypeName, MEETING.MeetingName,MEETING.Location," +
" MEETING.StartTime, MEETING.EndTime, MEETINGATTENDEES.AttendeeType," +
" MEETING.Prepared, MEETING.PreparedBy, MEETING.PreparedDateTime," +
" MEETING.BranchCode" +
" FROM MEETING, MEETINGTYPEMASTER, EMPLOYEEMASTER ,MEETINGATTENDEES," +
" DESIGNATIONMASTER, DEPARTMENTMASTER,USERMASTER" +
" Where MEETING.MeetingType=MEETINGTYPEMASTER.MeetingTypeCode" +
" And EMPLOYEEMASTER.EmployeeCode=MEETINGATTENDEES.EmployeeCode" +
" And EMPLOYEEMASTER.DepartmentCode=DEPARTMENTMASTER.DepartmentCode" +
" And EMPLOYEEMASTER.DesignationCode=DESIGNATIONMASTER.DesignationCode" +
" And MEETING.BranchCode=xxx" +
" And MEETING.MeetingNumber=MEETINGATTENDEES.MeetingNumber" +
" And MEETING.MeetingNumber= " + drMeeting["MeetingNumber"] + "" + //This meeting number coming from outer loop
" And EMPLOYEEMASTER.EmployeeCode=USERMASTER.EmployeeCode" +
" And USERMASTER.UserCode=2";//User code
scmd.Connection = CNN;
SqlDataAdapter sdaAttendies = new SqlDataAdapter(scmd);
sdaAttendies.Fill(dtAttendies);
if (dtAttendies.Rows.Count != 0)
{
foreach (DataRow drAttendies in dtAttendies.Rows)
{
lblMeetingType.Text = dtAttendies.Rows[0]["MeetingTypeName"].ToString();
lblMeetingName.Text = dtAttendies.Rows[0]["MeetingName"].ToString();
}
}
else
{ // if the user code has no meeting still the blank popup is coming
//Here no code is given but still the notification popup is coming
}
}
}
}
}
}
this.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
private void Form1_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
ShowInTaskbar = false;
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(1000);
}
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
ShowInTaskbar = true;
notifyIcon1.Visible = false;
WindowState = FormWindowState.Normal;
} public Form1()
{
InitializeComponent();
}
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
我无法找到错误。 请不要帮我显示通知消息。
谢谢, 拉马