Example #1
0
        void AddButton()
        {
            TaskAddForm taf = new TaskAddForm();
            if (taf.ShowDialog() == DialogResult.OK)
            {
                bool status;
                status = taf.StatusComboBox.Text == "Открыт";

                SqlConnection cn = new SqlConnection();
                cn = DBDevite.DBOpen();

                TaskDAL.InsertTask(TaskDAL.GetID(cn),
                                   Convert.ToInt32(taf.UserСomboBox.SelectedValue),
                                   Convert.ToInt32(taf.ClientComboBox.SelectedValue),
                                   taf.DateTimePicker.Value.Date,
                                   taf.TimeStartComboBox.Text,
                                   taf.TimeEndComboBox.Text,
                                   status,
                                   taf.AboutRichTextBox.Text, cn);

                DBDevite.DBClose(cn);

                //this.dataSetDevite.Reset();
                //this.tasksTableAdapter.Fill(this.dataSetDevite.Tasks);
                //this.dataGridViewTask.Update();
                GridReload(-1, -1);
            }
        }
Example #2
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (dataGridViewTask.RowCount != 0)
            {
                int focused = Convert.ToInt32(dataGridViewTask[0, dataGridViewTask.CurrentRow.Index].Value);
                TaskAddForm taf = new TaskAddForm();
                SqlConnection cn = new SqlConnection();
                try
                {
                    cn = DBDevite.DBOpen();

                    DataSet dt = TaskDAL.GetFullRecord(focused, cn);
                    taf.UserСomboBox.Text = dt.Tables[0].Rows[0]["Users"].ToString();
                    taf.ClientComboBox.Text = dt.Tables[0].Rows[0]["Name"].ToString();
                    taf.DateTimePicker.Value = Convert.ToDateTime(dt.Tables[0].Rows[0]["Date"].ToString());
                    if (dt.Tables[0].Rows[0]["TaskStatus"].ToString() == "True")
                        taf.StatusComboBox.Text = "Открыт";
                    else
                        taf.StatusComboBox.Text = "Закрыт";
                    taf.AboutRichTextBox.Text = dt.Tables[0].Rows[0]["About"].ToString();
                    taf.TimeStartComboBox.Text = dt.Tables[0].Rows[0]["TimeStart"].ToString();
                    taf.TimeEndComboBox.Text = dt.Tables[0].Rows[0]["TimeEnd"].ToString();

                    if (taf.ShowDialog() == DialogResult.OK)
                    {
                        bool status;
                        status = taf.StatusComboBox.Text == "Открыт";

                        TaskDAL.UpdateTask(focused,
                            Convert.ToInt32(taf.UserСomboBox.SelectedValue),
                            Convert.ToInt32(taf.ClientComboBox.SelectedValue),
                            taf.DateTimePicker.Value.Date,
                            taf.TimeStartComboBox.Text,
                            taf.TimeEndComboBox.Text,
                            status,
                            taf.AboutRichTextBox.Text, cn);

                       // this.tasksTableAdapter.Fill(this.dataSetDevite.Tasks);
                        GridReload(-1,-1);
                    }
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    DBDevite.DBClose(cn);
                }
            }
        }