Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                oMVotingSchedule = new Model.VotingSchedule();

                if (DateTimeValidation())
                {
                    oFrmMsgBox             = new Forms.frmMessageBox("THE DATE RANGE YOU HAVE SELECTED ARE INVALID OR END DATE ARE LESS THAN THE CURRENT DATE.");
                    oFrmMsgBox.MessageType = Forms.frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    LoadRecordDetails();
                    return;
                }

                oVotingSchedule = new DataAccess.SystemFunction();
                if (oVotingSchedule.IsScheduleExists())
                {
                    oMVotingSchedule.DATE_START = dtDateFrom.Value.ToString("yyyy-MM-dd");
                    oMVotingSchedule.TIME_START = dtTimeFrom.Value.ToString("h:mm:ss tt");
                    oMVotingSchedule.DATE_END   = dtDateTo.Value.ToString("yyyy-MM-dd");
                    oMVotingSchedule.TIME_END   = dtTimeTo.Value.ToString("h:mm:ss tt");
                    oMVotingSchedule.STATUS     = cboStatus.Text;

                    oVotingSchedule.UpdateSchedule(oMVotingSchedule);
                }

                LoadRecordDetails();
                MessageBox.Show("Record has been succesfully saved", sTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
        void LoadRecordDetails()
        {
            try
            {
                oVotingSchedule  = new DataAccess.SystemFunction();
                oMVotingSchedule = new Model.VotingSchedule();

                dgDetails.Rows.Clear();

                if (!oVotingSchedule.IsScheduleExists())
                {
                    oMVotingSchedule.DATE_END   = DateTime.Now.ToString("yyyy-MM-dd");
                    oMVotingSchedule.TIME_END   = DateTime.Now.ToString("h:mm:ss tt");
                    oMVotingSchedule.DATE_START = DateTime.Now.ToString("yyyy-MM-dd");
                    oMVotingSchedule.TIME_END   = DateTime.Now.ToString("h:mm:ss tt");
                    oMVotingSchedule.STATUS     = "CLOSED";
                    oVotingSchedule.InsertSchedule(oMVotingSchedule);
                }

                foreach (DataRow row in oVotingSchedule.GetVotingSchedule().Rows)
                {
                    dgDetails.Rows.Add(row["DATE_START"].ToString().Trim(), row["TIME_START"].ToString().Trim(), row["DATE_END"].ToString().Trim(), row["TIME_END"].ToString().Trim(), row["STATUS"].ToString().Trim());
                    sScheduleStatus = row["STATUS"].ToString().Trim();
                }


                if (CheckDateTime())
                {
                    oMVotingSchedule        = new Model.VotingSchedule();
                    oMVotingSchedule.STATUS = "CLOSED";
                    oVotingSchedule.UpdateSchedule(oMVotingSchedule);
                }

                if (sScheduleStatus != "CLOSED")
                {
                    lblStatus.ForeColor = Color.Lime;
                    lblStatus.Text      = "OPEN";
                }
                else
                {
                    lblStatus.ForeColor = Color.Red;
                    lblStatus.Text      = "CLOSED";
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #3
0
        public void UpdateSchedule(Model.VotingSchedule oData)
        {
            try
            {
                osb.ConnectionString = sConnectionString;
                ddq = new DatabaseQuery.DBQuery();
                ddq.ConnectionString = osb.ConnectionString;

                ddq.CommandText = "Update tbl_VotingSchedule set DATE_START = '" + oData.DATE_START + "',DATE_END = '" + oData.DATE_END + "', TIME_START  = '" + oData.TIME_START + "',TIME_END = '" + oData.TIME_END + "',STATUS =  '" + oData.STATUS + "'";
                ddq.ExecuteNonQuery(CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
        public void InsertSchedule(Model.VotingSchedule oData)
        {
            try
            {
                osb.ConnectionString = sConnectionString;
                ddq = new DatabaseQuery.DBQuery();
                ddq.ConnectionString = osb.ConnectionString;

                ddq.CommandText = "Insert Into tbl_VotingSchedule (DATE_START,DATE_END,TIME_START,TIME_END) Values ('" + oData.DATE_START + "','" + oData.DATE_END + "','" + oData.TIME_START + "','" + oData.TIME_END + "')";
                ddq.ExecuteNonQuery(CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #5
0
        void DatagridSelect(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                oMVotingSchedule = new Model.VotingSchedule();

                if (dgDetails.Rows.Count > 0)
                {
                    oMVotingSchedule.DATE_START = dgDetails.Rows[e.RowIndex].Cells[0].Value.ToString();
                    oMVotingSchedule.TIME_START = dgDetails.Rows[e.RowIndex].Cells[1].Value.ToString();
                    oMVotingSchedule.DATE_END   = dgDetails.Rows[e.RowIndex].Cells[2].Value.ToString();
                    oMVotingSchedule.TIME_END   = dgDetails.Rows[e.RowIndex].Cells[3].Value.ToString();
                    oMVotingSchedule.STATUS     = dgDetails.Rows[e.RowIndex].Cells[4].Value.ToString();
                }
            }
            catch (Exception ex)
            {
            }
        }