private void FrmCadetOccurrenceView_Load(object sender, EventArgs e)
      {
          lbllogger.Text = cadet.Name;

          try
          {
              string     query  = "SELECT Time,Task from KDUoccurrences where Occurrencedate = @Occurrencedate";
              SqlCommand sqlcmd = new SqlCommand();
              DataAccessLayer.AddParameters(sqlcmd, "@Occurrencedate", SqlDbType.DateTime, cadet.TodayDate);

              DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);

              if ((dt != null) && (dt.Rows.Count > 0))
              {
                  dgoccurrenceview.DataSource = dt;
              }
              else
              {
                  MessageBox.Show("No data found");
              }
          }
          catch (Exception ex)
          {
              this.Close();
              MessageBox.Show(ex.ToString());
          }
      }
        private void FrmCadetParadestate_Load(object sender, EventArgs e)
        {
            lbllogger.Text = cadet.Name;
            lbldate.Text   = cadet.TodayDate;

            try
            {
                SqlCommand sqlcmd1 = new SqlCommand();
                string     query1  = "Select Count(u.Id) from KDUusers u, KDUcadetinfo c where  u.Id=c.Id and c.Intake= @Intake";

                DataAccessLayer.AddParameters(sqlcmd1, "@Intake", SqlDbType.Int, cadet.Intake);

                DataTable dt = DataAccessLayer.ExecuteQuery(query1, sqlcmd1);

                if ((dt != null) && (dt.Rows.Count > 0))
                {
                    lblcount.Text = dt.Rows[0][0].ToString();

                    lblcount.Visible = true;
                }
                else
                {
                    MessageBox.Show("No matching Data");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void btnview_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmbintake.Text == "")
                {
                    MessageBox.Show("Please select an Intake");
                }
                else
                {
                    string query = "SELECT Totalcount,Presentcount,Absentcount,Submittedby,SubmittedOn from KDUrollcall  where Intake = @Intake and Rollcalldate = @Rollcalldate";

                    SqlCommand sqlcmd = new SqlCommand();
                    DataAccessLayer.AddParameters(sqlcmd, "@Rollcalldate", SqlDbType.DateTime, dtpdate.Value.ToString("yyyy-MM-dd"));
                    DataAccessLayer.AddParameters(sqlcmd, "@Intake", SqlDbType.Int, cmbintake.Text);
                    DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                    //if ((dt != null))
                    if ((dt != null) && (dt.Rows.Count > 0))
                    {
                        lblsubname.Text = dt.Rows[0]["Submittedby"].ToString();
                        lblsubdate.Text = dt.Rows[0]["SubmittedOn"].ToString();
                        lbltotal.Text   = dt.Rows[0]["Totalcount"].ToString();
                        lblpresent.Text = dt.Rows[0]["Presentcount"].ToString();
                        lblabsent.Text  = dt.Rows[0]["Absentcount"].ToString();



                        lblsubname.Visible = true;
                        lblsubdate.Visible = true;
                        lbltotal.Visible   = true;
                        lblpresent.Visible = true;
                        lblabsent.Visible  = true;
                    }
                    else
                    {
                        MessageBox.Show("No matching data");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            try
            {
                string query = "select d.Absentname from KDUrollcalldetails d, KDUrollcall r where r.Id=d.RollcallId and r.Intake = @Intake and r.Rollcalldate = @Rollcalldate";

                SqlCommand sqlcmd = new SqlCommand();
                DataAccessLayer.AddParameters(sqlcmd, "@Rollcalldate", SqlDbType.DateTime, dtpdate.Value.ToString("yyyy-MM-dd"));
                DataAccessLayer.AddParameters(sqlcmd, "@Intake", SqlDbType.Int, cmbintake.Text);

                DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);
                dgrollcall.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 4
0
        private void FrmCadetAttendanceView_Load(object sender, EventArgs e)
        {
            lbllogger.Text = cadet.Name;

            try
            {
                string     query  = "SELECT d.Absentname from KDUattendancedetails d,KDUattendance a where a.Id=d.AttendanceId and a.Attendancedate = @Attendancedate";
                SqlCommand sqlcmd = new SqlCommand();
                DataAccessLayer.AddParameters(sqlcmd, "@Attendancedate", SqlDbType.DateTime, cadet.TodayDate);

                DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                if ((dt != null))
                {
                    dgattendance.DataSource = dt;
                }
                else
                {
                    MessageBox.Show("No data found");
                }
            }
            catch (Exception ex)
            {
                this.Close();
                MessageBox.Show(ex.ToString());
            }
        }
        private void FrmCadetRollcallView_Load(object sender, EventArgs e)
        {
            try
            {
                string     query  = "SELECT d.Absentname from KDUrollcalldetails d,KDUrollcall r where r.Id=d.RollcallId and r.Rollcalldate = @Rollcalldate";
                SqlCommand sqlcmd = new SqlCommand();
                DataAccessLayer.AddParameters(sqlcmd, "@Rollcalldate", SqlDbType.DateTime, cadet.TodayDate);

                DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                if ((dt != null))
                {
                    dgrollcall.DataSource = dt;
                }
                else
                {
                    MessageBox.Show("No data found");
                }
            }
            catch (Exception ex)
            {
                this.Close();
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 6
0
        private void cmbintake_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(cmbintake.SelectedItem.ToString()))
                {
                    cmbcadetname.Items.Clear();
                    SqlCommand sqlcmd = new SqlCommand();
                    string     query  = "SELECT u.Id, u.Name FROM KDUusers u, KDUcadetinfo c WHERE u.Id = c.Id and c.Intake = @Intake";

                    DataAccessLayer.AddParameters(sqlcmd, "@Intake", SqlDbType.Int, cmbintake.SelectedItem.ToString());
                    DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                    foreach (DataRow dr in dt.Rows)
                    {
                        ComboboxItem citem = new ComboboxItem();
                        citem.Value = dr[0].ToString();
                        citem.Text  = dr[1].ToString();
                        cmbcadetname.Items.Add(citem);
                    }
                    //cmbcadetname.DataSource = dt;
                    //cmbcadetname.DisplayMember = "Name";
                    //cmbcadetname.ValueMember = "Id";
                    cmbcadetname.Text = "";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void btnview_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmbintake.Text == "")
                {
                    MessageBox.Show("Please select an Intake");
                }
                else
                {
                    string query = "select Time,Task from KDUoccurrences where Intake = @Intake and Occurrencedate = @Occurrencedate";

                    SqlCommand sqlcmd = new SqlCommand();
                    DataAccessLayer.AddParameters(sqlcmd, "@Occurrencedate", SqlDbType.DateTime, dtpoccurrence.Value.ToString("yyyy-MM-dd"));
                    DataAccessLayer.AddParameters(sqlcmd, "@Intake", SqlDbType.Int, cmbintake.Text);

                    DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);
                    if ((dt != null) && (dt.Rows.Count > 0))
                    {
                        dgoccurrence.DataSource = dt;
                    }
                    else
                    {
                        MessageBox.Show("No matching data");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            try
            {
                string query = "select SubmittedBy,SubmittedOn from KDUoccurrences where Intake = @Intake and Occurrencedate = @Occurrencedate";

                SqlCommand sqlcmd = new SqlCommand();
                DataAccessLayer.AddParameters(sqlcmd, "@Occurrencedate", SqlDbType.DateTime, dtpoccurrence.Value.ToString("yyyy-MM-dd"));
                DataAccessLayer.AddParameters(sqlcmd, "@Intake", SqlDbType.Int, cmbintake.Text);

                DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                if ((dt != null) && (dt.Rows.Count > 0))
                {
                    lblsubname.Text = dt.Rows[0]["SubmittedBy"].ToString();
                    lblsubdate.Text = dt.Rows[0]["SubmittedOn"].ToString();

                    lblsubname.Visible = true;
                    lblsubdate.Visible = true;
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 8
0
        private void cmbcadetname_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(cmbcadetname.SelectedItem.ToString()))
                {
                    string     query  = @"SELECT u.Name,u.Birthday,u.NICno,u.Contactno,u.Hometown,u.Emailaddress,u.Emergencycontactname,
                u.Emergencycontacttelephoneno,r.Religion,n.Nationality,g.Gendertype,i.Userphoto from KDUusers u, KDUgenders g, KDUnationality n,KDUreligion r,KDUcadetinfo i where 
                u.GenderId=g.Id and u.NationalityId=n.Id and i.Id=u.Id and u.ReligionId=r.Id and u.Id = @Id ";
                    SqlCommand sqlcmd = new SqlCommand();

                    DataAccessLayer.AddParameters(sqlcmd, "@Id", SqlDbType.Int, (cmbcadetname.SelectedItem as ComboboxItem).Value.ToString());
                    DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                    if ((dt != null) && (dt.Rows.Count == 1))
                    {
                        lblnamee.Text        = dt.Rows[0]["Name"].ToString();
                        lblhometownn.Text    = dt.Rows[0]["Hometown"].ToString();
                        lblbdayy.Text        = Convert.ToDateTime(dt.Rows[0]["Birthday"]).ToString("yyyy-MM-dd");
                        lblgenderr.Text      = dt.Rows[0]["Gendertype"].ToString();
                        lblnicc.Text         = dt.Rows[0]["NICno"].ToString();
                        lblnationalityy.Text = dt.Rows[0]["Nationality"].ToString();
                        lblreligionn.Text    = dt.Rows[0]["Religion"].ToString();
                        lbltpp.Text          = dt.Rows[0]["Contactno"].ToString();
                        lblemaill.Text       = dt.Rows[0]["Emailaddress"].ToString();
                        lblemenamee.Text     = dt.Rows[0]["Emergencycontactname"].ToString();
                        lblemetpp.Text       = dt.Rows[0]["Emergencycontacttelephoneno"].ToString();

                        var pic = Convert.FromBase64String(dt.Rows[0]["Userphoto"].ToString());
                        using (MemoryStream ms = new MemoryStream(pic))
                        {
                            pbcadetview.Image = Image.FromStream(ms);
                        }


                        lblnamee.Visible        = true;
                        lblhometownn.Visible    = true;
                        lblbdayy.Visible        = true;
                        lblgenderr.Visible      = true;
                        lblnicc.Visible         = true;
                        lblnationalityy.Visible = true;
                        lblreligionn.Visible    = true;
                        lbltpp.Visible          = true;
                        lblemaill.Visible       = true;
                        lblemenamee.Visible     = true;
                        lblemetpp.Visible       = true;
                    }
                    else
                    {
                        MessageBox.Show("No matching data");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 9
0
        private void btnview_Click(object sender, EventArgs e)
        {
            try
            {
                string     query  = "SELECT Lunch,Dinner,Breakfast,Remarklunch,Remarkdinner,Remarkbreakfast,Comments,SubmittedBy,SubmittedOn from KDUmeals where Intake = @Intake and Mealdate = @Mealdate";
                SqlCommand sqlcmd = new SqlCommand();
                DataAccessLayer.AddParameters(sqlcmd, "@Mealdate", SqlDbType.DateTime, dtpmeals.Value.ToString("yyyy-MM-dd"));
                DataAccessLayer.AddParameters(sqlcmd, "@Intake", SqlDbType.Int, cmbintake.Text);
                DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                if ((dt != null) && (dt.Rows.Count == 1))
                {
                    lbllunch.Text     = dt.Rows[0]["Lunch"].ToString();
                    lbldinner.Text    = dt.Rows[0]["Dinner"].ToString();
                    lblbreakfast.Text = dt.Rows[0]["Breakfast"].ToString();
                    lblremarks.Text   = dt.Rows[0]["Remarklunch"].ToString();
                    lblcomments.Text  = dt.Rows[0]["Comments"].ToString();
                    lblsubname.Text   = dt.Rows[0]["SubmittedBy"].ToString();
                    lblsubdate.Text   = dt.Rows[0]["SubmittedOn"].ToString();
                    lblremarks1.Text  = dt.Rows[0]["Remarkdinner"].ToString();
                    lblremarks2.Text  = dt.Rows[0]["Remarkbreakfast"].ToString();

                    lbllunch.MaximumSize     = new Size(200, 0);
                    lbllunch.AutoSize        = true;
                    lbldinner.MaximumSize    = new Size(200, 0);
                    lbldinner.AutoSize       = true;
                    lblbreakfast.MaximumSize = new Size(200, 0);
                    lblbreakfast.AutoSize    = true;
                    lblcomments.MaximumSize  = new Size(300, 0);
                    lblcomments.AutoSize     = true;


                    lbllunch.Visible     = true;
                    lbldinner.Visible    = true;
                    lblbreakfast.Visible = true;
                    lblremarks.Visible   = true;
                    lblcomments.Visible  = true;
                    lblsubname.Visible   = true;
                    lblsubdate.Visible   = true;
                    lblremarks1.Visible  = true;
                    lblremarks2.Visible  = true;
                }
                else
                {
                    //cmbintake.Text = "";

                    MessageBox.Show("No matching data");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 10
0
        private void FrmParadeView_Load(object sender, EventArgs e)
        {
            lbllogger.Text = cadet.Name;
            try
            {
                string query = "SELECT SVCCadets,Onparade,Notonparade,AttendA,AttendB,AttendC,ExPT,Sickreports,MIroom,Hospital,Leave,ExtraClasses,Others from KDUparadestate where Paradedate = @Paradedate";

                SqlCommand sqlcmd = new SqlCommand();
                DataAccessLayer.AddParameters(sqlcmd, "@Paradedate", SqlDbType.DateTime, cadet.TodayDate);
                DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);
                if ((dt != null) && (dt.Rows.Count == 1))
                {
                    lblcountsvc.Text      = dt.Rows[0]["SVCCadets"].ToString();
                    lblcounton.Text       = dt.Rows[0]["Onparade"].ToString();
                    lblcountnot.Text      = dt.Rows[0]["Notonparade"].ToString();
                    lblcountA.Text        = dt.Rows[0]["AttendA"].ToString();
                    lblcountB.Text        = dt.Rows[0]["AttendB"].ToString();
                    lblcountC.Text        = dt.Rows[0]["AttendC"].ToString();
                    lblcountexpt.Text     = dt.Rows[0]["ExPT"].ToString();
                    lblcountsick.Text     = dt.Rows[0]["Sickreports"].ToString();
                    lblcountmi.Text       = dt.Rows[0]["MIroom"].ToString();
                    lblcounthospital.Text = dt.Rows[0]["Hospital"].ToString();
                    lblcountleave.Text    = dt.Rows[0]["Leave"].ToString();
                    lblcountextra.Text    = dt.Rows[0]["ExtraClasses"].ToString();
                    lblotherdetails.Text  = dt.Rows[0]["Others"].ToString();

                    lblotherdetails.MaximumSize = new Size(400, 0);
                    lblotherdetails.AutoSize    = true;

                    lblcountsvc.Visible      = true;
                    lblcounton.Visible       = true;
                    lblcountnot.Visible      = true;
                    lblcountA.Visible        = true;
                    lblcountB.Visible        = true;
                    lblcountC.Visible        = true;
                    lblcountexpt.Visible     = true;
                    lblcountsick.Visible     = true;
                    lblcountmi.Visible       = true;
                    lblcounthospital.Visible = true;
                    lblcountleave.Visible    = true;
                    lblcountextra.Visible    = true;
                    lblotherdetails.Visible  = true;
                }
                else
                {
                    MessageBox.Show("No data found");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void FrmAdminAddOfficer_Load(object sender, EventArgs e)
        {
            lbllogger.Text = admin.Name;

            try
            {
                SqlCommand sqlcmd = new SqlCommand();
                string     query  = "Select  Id, Gendertype from KDUgenders";
                DataTable  dt     = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                cmbgender.DataSource    = dt;
                cmbgender.DisplayMember = "Gendertype";
                cmbgender.ValueMember   = "Id";
                cmbgender.Text          = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }


            try
            {
                SqlCommand sqlcmd = new SqlCommand();
                string     query  = "Select Id,Nationality from KDUnationality";
                DataTable  dt     = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                cmbnationality.DataSource    = dt;
                cmbnationality.DisplayMember = "Nationality";
                cmbnationality.ValueMember   = "Id";
                cmbnationality.Text          = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            try
            {
                SqlCommand sqlcmd = new SqlCommand();
                string     query  = "Select Id,Religion from KDUreligion";
                DataTable  dt     = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                cmbreligion.DataSource    = dt;
                cmbreligion.DisplayMember = "Religion";
                cmbreligion.ValueMember   = "Id";
                cmbreligion.Text          = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void FrmOfficerprofile_Load(object sender, EventArgs e)
        {
            lbllogger.Text = oofficer.Name;

            try
            {
                string query = @"SELECT u.Name,u.Birthday,u.NICno,u.Contactno,u.Hometown,u.Emailaddress,u.Emergencycontactname,
                    u.Emergencycontacttelephoneno,g.Gendertype,n.Nationality,r.Religion,i.Userphoto FROM KDUofficerinfo i,KDUusers u,KDUgenders g,KDUnationality n,KDUreligion r where Name = @Name and u.GenderId=g.Id and u.NationalityId=n.Id and u.ReligionId=r.Id ";

                SqlCommand sqlcmd = new SqlCommand();

                DataAccessLayer.AddParameters(sqlcmd, "@Name", SqlDbType.NVarChar, oofficer.Name);
                DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);


                lblnamee.Text        = dt.Rows[0]["Name"].ToString();
                lblhometownn.Text    = dt.Rows[0]["Hometown"].ToString();
                lblbdayy.Text        = Convert.ToDateTime(dt.Rows[0]["Birthday"]).ToString("yyyy-MM-dd");
                lblgenderr.Text      = dt.Rows[0]["Gendertype"].ToString();
                lblnicc.Text         = dt.Rows[0]["NICno"].ToString();
                lblnationalityy.Text = dt.Rows[0]["Nationality"].ToString();
                lblreligionn.Text    = dt.Rows[0]["Religion"].ToString();
                lbltpp.Text          = dt.Rows[0]["Contactno"].ToString();
                lblemaill.Text       = dt.Rows[0]["Emailaddress"].ToString();
                lblemenamee.Text     = dt.Rows[0]["Emergencycontactname"].ToString();
                lblemetpp.Text       = dt.Rows[0]["Emergencycontacttelephoneno"].ToString();

                var pic = Convert.FromBase64String(dt.Rows[0]["Userphoto"].ToString());
                using (MemoryStream ms = new MemoryStream(pic))
                {
                    pictureBox1.Image = Image.FromStream(ms);
                }



                lblnamee.Visible        = true;
                lblhometownn.Visible    = true;
                lblbdayy.Visible        = true;
                lblgenderr.Visible      = true;
                lblnicc.Visible         = true;
                lblnationalityy.Visible = true;
                lblreligionn.Visible    = true;
                lbltpp.Visible          = true;
                lblemaill.Visible       = true;
                lblemenamee.Visible     = true;
                lblemetpp.Visible       = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 13
0
 private DataTable GetAllCadetList()
 {
     try
     {
         SqlCommand sqlcmd = new SqlCommand();
         string     query  = "Select u.Name from KDUusers u, KDUcadetinfo c where u.Id=c.Id and c.Intake = @Intake";
         DataAccessLayer.AddParameters(sqlcmd, "@Intake", SqlDbType.Int, cadet.Intake);
         return(DataAccessLayer.ExecuteQuery(query, sqlcmd));
     }
     catch (Exception ex)
     {
         MessageBox.Show("No data found");
         return(null);
     }
 }
      private void FrmViewMeals_Load(object sender, EventArgs e)
      {
          lbllogger.Text = cadet.Name;
          try
          {
              string     query  = "SELECT Lunch,Dinner,Breakfast,Remarklunch,Remarkdinner,Remarkbreakfast,Comments from KDUmeals where Mealdate = @Mealdate";
              SqlCommand sqlcmd = new SqlCommand();
              DataAccessLayer.AddParameters(sqlcmd, "@Mealdate", SqlDbType.DateTime, cadet.TodayDate);

              DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);

              if ((dt != null) && (dt.Rows.Count == 1))
              {
                  lbllunch.Text     = dt.Rows[0]["Lunch"].ToString();
                  lbldinner.Text    = dt.Rows[0]["Dinner"].ToString();
                  lblbreakfast.Text = dt.Rows[0]["Breakfast"].ToString();
                  lblremarks.Text   = dt.Rows[0]["Remarklunch"].ToString();
                  lblcomments.Text  = dt.Rows[0]["Comments"].ToString();
                  lblremarks1.Text  = dt.Rows[0]["Remarkdinner"].ToString();
                  lblremarks2.Text  = dt.Rows[0]["Remarkbreakfast"].ToString();


                  lbllunch.MaximumSize     = new Size(200, 0);
                  lbllunch.AutoSize        = true;
                  lbldinner.MaximumSize    = new Size(200, 0);
                  lbldinner.AutoSize       = true;
                  lblbreakfast.MaximumSize = new Size(200, 0);
                  lblbreakfast.AutoSize    = true;

                  lbllunch.Visible     = true;
                  lbldinner.Visible    = true;
                  lblbreakfast.Visible = true;
                  lblremarks.Visible   = true;
                  lblcomments.Visible  = true;
                  lblremarks1.Visible  = true;
                  lblremarks2.Visible  = true;
              }
              else
              {
                  MessageBox.Show("No data found");
              }
          }
          catch (Exception ex)
          {
              this.Close();
              MessageBox.Show(ex.ToString());
          }
      }
        private int GetCadetIntake(int id)
        {
            int    intake = 0;
            string query  = "SELECT Intake FROM KDUcadetInfo WHERE Id = @Id";

            SqlCommand sqlcmd = new SqlCommand();

            DataAccessLayer.AddParameters(sqlcmd, "@Id", SqlDbType.Int, id);
            DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);

            //Got data
            if ((dt != null) && (dt.Rows.Count == 1))
            {
                intake = Convert.ToInt32(dt.Rows[0]["Intake"]);
            }
            return(intake);
        }
Exemplo n.º 16
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            SqlCommand sqlcmd = new SqlCommand();
            string     query  = @"INSERT INTO KDUattendance(Attendancedate,Intake,Totalcount,Presentcount,Absentcount,Submittedby,SubmittedOn)VALUES(@Attendancedate,@Intake,@Totalcount,@Presentcount,@Absentcount,@Submittedby,GETDATE())";

            DataAccessLayer.AddParameters(sqlcmd, "@Attendancedate", SqlDbType.DateTime, cadet.TodayDate);
            DataAccessLayer.AddParameters(sqlcmd, "@Intake", SqlDbType.Int, cadet.Intake);
            DataAccessLayer.AddParameters(sqlcmd, "@Totalcount", SqlDbType.Int, lbltotal.Text);
            DataAccessLayer.AddParameters(sqlcmd, "@Presentcount", SqlDbType.Int, lblpresent.Text);
            DataAccessLayer.AddParameters(sqlcmd, "@Absentcount", SqlDbType.Int, lblabsent.Text);
            DataAccessLayer.AddParameters(sqlcmd, "@Submittedby", SqlDbType.NVarChar, cadet.Name);

            DataAccessLayer.ExecuteNonQuery(query, sqlcmd);

            SqlCommand sqlcmd0 = new SqlCommand();
            string     query0  = "SELECT Id FROM KDUattendance WHERE Intake=@Intake AND Attendancedate=@Attendancedate";

            DataAccessLayer.AddParameters(sqlcmd0, "@Intake", SqlDbType.Int, cadet.Intake);
            DataAccessLayer.AddParameters(sqlcmd0, "@Attendancedate", SqlDbType.DateTime, cadet.TodayDate);


            DataTable dtid         = DataAccessLayer.ExecuteQuery(query0, sqlcmd0);
            int       attendanceid = 0;

            if ((dtid != null) && (dtid.Rows.Count > 0))
            {
                attendanceid = Convert.ToInt32(dtid.Rows[0]["Id"]);
            }


            foreach (DataRow dr in dtAbsentCadets.Rows)
            {
                SqlCommand sqlcmd1 = new SqlCommand();
                string     query1  = "INSERT INTO KDUattendancedetails(AttendanceId,Absentname)VALUES(@AttendanceId,@Absentname)";
                DataAccessLayer.AddParameters(sqlcmd1, "@AttendanceId", SqlDbType.Int, attendanceid);
                DataAccessLayer.AddParameters(sqlcmd1, "@Absentname", SqlDbType.NVarChar, dr[0].ToString());

                DataAccessLayer.ExecuteNonQuery(query1, sqlcmd1);
            }
            MessageBox.Show("Saved Successfully");

            lbltotal.Text     = "";
            lblpresent.Text   = "";
            lblabsent.Text    = "";
            dgattendance.Text = "";
        }
Exemplo n.º 17
0
        private void FrmOfficerMeals_Load(object sender, EventArgs e)
        {
            lbllogger.Text = oofficer.Name;
            try
            {
                SqlCommand sqlcmd = new SqlCommand();
                string     query  = "Select distinct Intake from KDUcadetinfo ";
                DataTable  dt     = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                cmbintake.DataSource    = dt;
                cmbintake.DisplayMember = "Intake";
                cmbintake.Text          = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void FrmOfficerAnnouncements_Load(object sender, EventArgs e)
        {
            lbllogger.Text = oofficer.Name;
            lbldate.Text   = oofficer.TodayDate;

            try
            {
                SqlCommand sqlcmd = new SqlCommand();
                string     query  = "Select distinct Intake from KDUcadetinfo ";
                DataTable  dt     = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                foreach (DataRow dr in dt.Rows)
                {
                    cmbintake.Items.Add(dr[0].ToString());
                }

                cmbintake.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 19
0
        private void FrmOfficerCadetView_Load(object sender, EventArgs e)
        {
            lbllogger.Text = oofficer.Name;
            try
            {
                SqlCommand sqlcmd = new SqlCommand();
                string     query  = "Select distinct Intake from KDUcadetinfo ";
                DataTable  dt     = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                foreach (DataRow dr in dt.Rows)
                {
                    cmbintake.Items.Add(dr[0].ToString());
                }

                //cmbintake.DataSource = dt;
                //cmbintake.DisplayMember = "Intake";
                //cmbintake.ValueMember = "Intake";
                cmbintake.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void btngo_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtusername.Text == "")
                {
                    MessageBox.Show("User ID is required");
                }
                else if (txtpassword.Text == "")
                {
                    MessageBox.Show("Password is required");
                }
                else if (txtusername.Text.Length > 9)
                {
                    MessageBox.Show("Please input valid username");
                }
                else
                {
                    //Username ok. Password ok. Now Login user.
                    string query = @"SELECT Id, Userid,Userpassword,Name, UsertypeId, GETDATE() AS 'TodayDate' 
                        FROM KDUusers WHERE Userid = @Userid AND Userpassword = @Userpassword AND UserStatusId = " + UserStatusId.Active.ToString();

                    SqlCommand sqlcmd = new SqlCommand();
                    DataAccessLayer.AddParameters(sqlcmd, "@Userid", SqlDbType.Int, txtusername.Text);
                    DataAccessLayer.AddParameters(sqlcmd, "@Userpassword", SqlDbType.NVarChar, txtpassword.Text);
                    DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);
                    //Got data

                    if ((dt != null) && (dt.Rows.Count == 1))
                    {
                        //user found
                        int usertypeid = Convert.ToInt32(dt.Rows[0]["UsertypeId"]);

                        if (usertypeid == UserTypeId.Cadet)
                        {
                            Ocadet c = new Ocadet();
                            c.Id        = Convert.ToInt32(dt.Rows[0]["Id"]);
                            c.Name      = dt.Rows[0]["Name"].ToString();
                            c.Userid    = Convert.ToInt32(dt.Rows[0]["Userid"]);
                            c.Password  = dt.Rows[0]["Userpassword"].ToString();
                            c.Intake    = GetCadetIntake(Convert.ToInt32(dt.Rows[0]["Id"]));
                            c.TodayDate = Convert.ToDateTime(dt.Rows[0]["TodayDate"]).ToString("yyyy-MM-dd");


                            FrmCadetHome cdthm = new FrmCadetHome(c);
                            cdthm.Show();
                            this.Close();
                        }
                        else if (usertypeid == UserTypeId.Officer)
                        {
                            Officer o = new Officer();
                            o.Id        = Convert.ToInt32(dt.Rows[0]["Id"]);
                            o.Name      = dt.Rows[0]["Name"].ToString();
                            o.Userid    = Convert.ToInt32(dt.Rows[0]["Userid"]);
                            o.Password  = dt.Rows[0]["Userpassword"].ToString();
                            o.TodayDate = Convert.ToDateTime(dt.Rows[0]["TodayDate"]).ToString("yyyy-MM-dd");

                            FrmOfficerHome ofhm = new FrmOfficerHome(o);
                            ofhm.Show();
                            this.Close();
                        }
                        else if (usertypeid == UserTypeId.Instructor)
                        {
                            Instructor a = new Instructor();
                            a.Id       = Convert.ToInt32(dt.Rows[0]["Id"]);
                            a.Name     = dt.Rows[0]["Name"].ToString();
                            a.Userid   = Convert.ToInt32(dt.Rows[0]["Userid"]);
                            a.Password = dt.Rows[0]["Userpassword"].ToString();

                            FrmAdminHome adhm = new FrmAdminHome(a);
                            adhm.Show();
                            this.Close();
                        }
                    }
                    else
                    {
                        //user not found
                        txtusername.Clear();
                        txtpassword.Clear();
                        MessageBox.Show("Check your Login Details!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void btnview_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmbintake.Text == "")
                {
                    MessageBox.Show("Please select an Intake");
                }
                else
                {
                    string query = "SELECT SVCCadets,Onparade,Notonparade,AttendA,AttendB,AttendC,ExPT,Sickreports,MIroom,Hospital,Leave,ExtraClasses,Others,SubmittedBy,SubmittedOn from KDUparadestate where Intake = @Intake and Paradedate= @Paradedate";

                    SqlCommand sqlcmd = new SqlCommand();
                    DataAccessLayer.AddParameters(sqlcmd, "@Paradedate", SqlDbType.DateTime, dtpdate.Value.ToString("yyyy-MM-dd"));
                    DataAccessLayer.AddParameters(sqlcmd, "@Intake", SqlDbType.Int, cmbintake.Text);
                    DataTable dt = DataAccessLayer.ExecuteQuery(query, sqlcmd);

                    if ((dt != null) && (dt.Rows.Count > 0))
                    {
                        lblcountsvc.Text      = dt.Rows[0]["SVCCadets"].ToString();
                        lblcounton.Text       = dt.Rows[0]["Onparade"].ToString();
                        lblcountnot.Text      = dt.Rows[0]["Notonparade"].ToString();
                        lblcountA.Text        = dt.Rows[0]["AttendA"].ToString();
                        lblcountB.Text        = dt.Rows[0]["AttendB"].ToString();
                        lblcountC.Text        = dt.Rows[0]["AttendC"].ToString();
                        lblcountexpt.Text     = dt.Rows[0]["ExPT"].ToString();
                        lblcountsick.Text     = dt.Rows[0]["Sickreports"].ToString();
                        lblcountmi.Text       = dt.Rows[0]["MIroom"].ToString();
                        lblcounthospital.Text = dt.Rows[0]["Hospital"].ToString();
                        lblcountleave.Text    = dt.Rows[0]["Leave"].ToString();
                        lblcountextra.Text    = dt.Rows[0]["ExtraClasses"].ToString();
                        lblotherdetails.Text  = dt.Rows[0]["Others"].ToString();
                        lblsubname.Text       = dt.Rows[0]["SubmittedBy"].ToString();
                        lblsubdate.Text       = dt.Rows[0]["SubmittedOn"].ToString();

                        lblotherdetails.MaximumSize = new Size(400, 0);
                        lblotherdetails.AutoSize    = true;


                        lblcountsvc.Visible      = true;
                        lblcounton.Visible       = true;
                        lblcountnot.Visible      = true;
                        lblcountA.Visible        = true;
                        lblcountB.Visible        = true;
                        lblcountC.Visible        = true;
                        lblcountexpt.Visible     = true;
                        lblcountsick.Visible     = true;
                        lblcountmi.Visible       = true;
                        lblcounthospital.Visible = true;
                        lblcountleave.Visible    = true;
                        lblcountextra.Visible    = true;
                        lblotherdetails.Visible  = true;
                        lblsubname.Visible       = true;
                        lblsubdate.Visible       = true;
                    }
                    else
                    {
                        MessageBox.Show("No matching data");
                        lblcountsvc.Text      = "";
                        lblcounton.Text       = "";
                        lblcountnot.Text      = "";
                        lblcountA.Text        = "";
                        lblcountB.Text        = "";
                        lblcountC.Text        = "";
                        lblcountexpt.Text     = "";
                        lblcountsick.Text     = "";
                        lblcountmi.Text       = "";
                        lblcounthospital.Text = "";
                        lblcountleave.Text    = "";
                        lblcountextra.Text    = "";
                        lblotherdetails.Text  = "";
                        lblsubname.Text       = "";
                        lblsubdate.Text       = "";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void btnsave_Click(object sender, EventArgs e)
        {
            if (txtname.Text == "" || txttown.Text == "" || cmbgender.Text == "" ||
                txtbday.Text == "" || txtnic.Text == "" || cmbnationality.Text == "" ||
                cmbreligion.Text == "" || txttp.Text == "" || txtemail.Text == "" ||
                txtemename.Text == "" || txtemetp.Text == "" || txtrank.Text == "" ||
                txtpassword.Text == "" || txtid.Text == "")

            {
                MessageBox.Show("Please fill the required fields.", "Message", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
            }
            else
            {
                SqlCommand sqlcmd = new SqlCommand();
                string     query  = @"INSERT INTO KDUusers(Userid,Userpassword,Name,Birthday,NICno,GenderId,NationalityId,ReligionId,Contactno,Hometown,Emailaddress,Emergencycontactname,
                    Emergencycontacttelephoneno,UsertypeId,UserstatusId)VALUES(@Userid,@Userpassword,@Name,@Birthday,@NICno,@GenderId,@NationalityId,@ReligionId,@Contactno,@Hometown,@Emailaddress,@Emergencycontactname,
                    @Emergencycontacttelephoneno,@UsertypeId,@UserstatusId)";

                DataAccessLayer.AddParameters(sqlcmd, "@Name", SqlDbType.NVarChar, txtname.Text);
                DataAccessLayer.AddParameters(sqlcmd, "@Hometown", SqlDbType.NVarChar, txttown.Text);
                DataAccessLayer.AddParameters(sqlcmd, "@Birthday", SqlDbType.Date, txtbday.Text);
                DataAccessLayer.AddParameters(sqlcmd, "@NICno", SqlDbType.NVarChar, txtnic.Text);
                DataAccessLayer.AddParameters(sqlcmd, "@Contactno", SqlDbType.Int, txttp.Text);
                DataAccessLayer.AddParameters(sqlcmd, "@Emailaddress", SqlDbType.NVarChar, txtemail.Text);
                DataAccessLayer.AddParameters(sqlcmd, "@Emergencycontactname", SqlDbType.NVarChar, txtemename.Text);
                DataAccessLayer.AddParameters(sqlcmd, "@Emergencycontacttelephoneno", SqlDbType.Int, txtemetp.Text);
                DataAccessLayer.AddParameters(sqlcmd, "@Userpassword", SqlDbType.NVarChar, txtpassword.Text);
                DataAccessLayer.AddParameters(sqlcmd, "@Userid", SqlDbType.Int, txtid.Text);
                DataAccessLayer.AddParameters(sqlcmd, "@GenderId", SqlDbType.Int, cmbgender.SelectedValue.ToString());
                DataAccessLayer.AddParameters(sqlcmd, "@NationalityId", SqlDbType.Int, cmbnationality.SelectedValue.ToString());
                DataAccessLayer.AddParameters(sqlcmd, "@ReligionId", SqlDbType.Int, cmbreligion.SelectedValue.ToString());
                DataAccessLayer.AddParameters(sqlcmd, "@UsertypeId", SqlDbType.Int, UserTypeId.Officer);
                DataAccessLayer.AddParameters(sqlcmd, "@UserstatusId", SqlDbType.Int, UserStatusId.Active);

                DataAccessLayer.ExecuteNonQuery(query, sqlcmd);

                SqlCommand sqlcmd0 = new SqlCommand();
                string     query0  = "SELECT Id FROM KDUusers WHERE NICno = @NICno AND UsertypeId =" + UserTypeId.Officer.ToString();
                DataAccessLayer.AddParameters(sqlcmd0, "@NICno", SqlDbType.NVarChar, txtnic.Text);
                DataAccessLayer.AddParameters(sqlcmd0, "@UsertypeId", SqlDbType.Int, UserTypeId.Officer);
                DataTable dtid      = DataAccessLayer.ExecuteQuery(query0, sqlcmd0);
                int       officerid = 0;
                if ((dtid != null) && (dtid.Rows.Count == 1))
                {
                    officerid = Convert.ToInt32(dtid.Rows[0]["Id"]);
                }

                string img = string.Empty;

                if (!string.IsNullOrEmpty(lblImgPath.Text))
                {
                    using (Image image = Image.FromFile(lblImgPath.Text))
                    {
                        using (MemoryStream m = new MemoryStream())
                        {
                            image.Save(m, image.RawFormat);
                            byte[] imageBytes = m.ToArray();

                            // Convert byte[] to Base64 String
                            img = Convert.ToBase64String(imageBytes);
                        }
                    }
                }

                SqlCommand sqlcmd1 = new SqlCommand();
                string     query1  = @"INSERT INTO KDUofficerinfo(Id,Rank,Userphoto)VALUES(@officerid,@Rank,@Userphoto)";
                DataAccessLayer.AddParameters(sqlcmd1, "@officerid", SqlDbType.Int, officerid);
                DataAccessLayer.AddParameters(sqlcmd1, "@Rank", SqlDbType.NVarChar, txtrank.Text);
                DataAccessLayer.AddParameters(sqlcmd1, "@Userphoto", SqlDbType.NVarChar, img);
                DataAccessLayer.ExecuteNonQuery(query1, sqlcmd1);


                MessageBox.Show("Saved Successfully");

                txtname.Text        = "";
                txttown.Text        = "";
                cmbgender.Text      = "";
                txtbday.Text        = "";
                txtnic.Text         = "";
                cmbnationality.Text = "";
                cmbreligion.Text    = "";
                txttp.Text          = "";
                txtemail.Text       = "";
                txtemename.Text     = "";
                txtemetp.Text       = "";
                txtpassword.Text    = "";
                txtid.Text          = "";
                txtrank.Text        = "";
                pbcadetpic.Image    = null;
            }
        }