在C#表单中,即使没有编写代码,也会填充表单 [英] in C# forms ,Form is populated even no code is written

查看:52
本文介绍了在C#表单中,即使没有编写代码,也会填充表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我正在编写程序来创建系统托盘以弹出消息。

I am writing program to create system tray to popup messages.

在程序中我检查它是否有效用户然后将显示通知

in the program i check if it is valid user then notification will be displayed

不会显示任何通知消息。

no notification message will be displayed.

但是如果用户(用户代码)没有会议,然后空白通知消息弹出即将到来。

But if the user(user code) has no meeting then blank notification message popup is coming.

我想隐藏通知消息。

请帮助我。

我已编写代码

  


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 } } }

}
}

}
这个。关();
}

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);
}
}

} } } 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;            
        }

 private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ShowInTaskbar = true;
            notifyIcon1.Visible = false;
            WindowState = FormWindowState.Normal;            
        }

 静态课程计划
    {
              [STAThread]
        static void Main()
        {            
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(假);
                Application.Run(new Form1());
            }
          }

 static class Program
    {
              [STAThread]
        static void Main()
        {            
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
          }


  

我无法纠正错误。

  

I am unable to rectify the error.

请帮我不要显示通知消息

Please help me not to display notification message

谢谢

Rama

推荐答案

你好chandran.nr123,

Hi chandran.nr123,

我做看不到任何函数notifyIcon1,你正在填充数据。为什么不放这样的东西:

I do not see any function notifyIcon1 that you are populating with the data. Why not put something like this:

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
   notifyIcon1.Visible = false;

}


或,设置 if条件以检查数据表是否包含任何数据

or, put an if condition to check whether you datatable contains any data or not.


这篇关于在C#表单中,即使没有编写代码,也会填充表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆