Exemplo n.º 1
0
        public void ShowDialog(Task oTask)
        {
            txtTaskCode.Text = oTask.TaskCode;
            txtTaskDescription.Text = oTask.TaskDescription;
            dtpTaskDate.Value = oTask.TaskDate;
            cmbTaskStatus.Text = oTask.TaskStatus;
            txtRemarks.Text = oTask.Remarks;

            this.Tag = oTask;
            this.ShowDialog();
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Task oTask;
            if (this.Tag == null)
            {
                oTask = new Task();
                oTask.TaskCode = txtTaskCode.Text;
                oTask.TaskDescription = txtTaskDescription.Text;
                oTask.TaskDate = dtpTaskDate.Value;
                oTask.TaskStatus = cmbTaskStatus.Text;
                oTask.Remarks = txtRemarks.Text;
                try
                {
                    DBController.Instance.BeginNewTransaction();
                    oTask.Add();
                    DBController.Instance.CommitTransaction();
                    MessageBox.Show("You Have Successfully Save The Task : " + oTask.TaskCode, "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
                catch (Exception ex)
                {
                    DBController.Instance.RollbackTransaction();
                    MessageBox.Show(ex.Message, "Error!!!");
                }
            }
            else
            {
                oTask = (Task)this.Tag;
                oTask.TaskCode = txtTaskCode.Text;
                oTask.TaskDescription = txtTaskDescription.Text;
                oTask.TaskDate = dtpTaskDate.Value;
                oTask.TaskStatus = cmbTaskStatus.Text;
                oTask.Remarks = txtRemarks.Text;

                try
                {
                    DBController.Instance.BeginNewTransaction();
                    oTask.Edit();
                    DBController.Instance.CommitTransaction();
                    MessageBox.Show("You Have Successfully Update the Task: " + oTask.TaskCode, "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
                catch (Exception ex)
                {
                    DBController.Instance.RollbackTransaction();
                    MessageBox.Show(ex.Message, "Error!!!");
                }
            }

            this.Close();
        }
Exemplo n.º 3
0
        public void Refresh()
        {
            InnerList.Clear();
                OleDbCommand myCmd = DBController.Instance.GetCommand();
                string sSql = "";

                try
                {
                    sSql = "SELECT * FROM t_Task";
                    myCmd.CommandText = sSql;
                    myCmd.CommandType = CommandType.Text;
                    IDataReader reader = myCmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Task oTask = new Task();

                        oTask.TaskID = (int)reader["TaskID"];
                        oTask.TaskCode = (string)reader["TaskCode"];
                        oTask.TaskDescription = (string)reader["TaskDescription"];
                        oTask.TaskDate = (DateTime)reader["TaskDate"];
                        oTask.TaskStatus = (string)reader["TaskStatus"];
                        oTask.Remarks = (string)reader["Remarks"];

                        InnerList.Add(oTask);
                    }
                    reader.Close();
                    InnerList.TrimToSize();

                }
                catch (Exception ex)
                {
                    throw (ex);
                }
        }