Пример #1
0
 private void templateGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == templateGridView.Columns["Column2"].Index && e.RowIndex >= 0)
     {
         EditTextTemplate edtexttemplate = new EditTextTemplate(templates[e.RowIndex]);
         edtexttemplate.Show();
     }
     else if (e.ColumnIndex == templateGridView.Columns["Column3"].Index && e.RowIndex >= 0)
     {
         EditReceiversOfTemplate editReceivers = new EditReceiversOfTemplate(templates[e.RowIndex].id);
         editReceivers.Show();
     }
     else if (e.ColumnIndex == templateGridView.Columns["Column7"].Index && e.RowIndex >= 0)
     {
         EditDateTemplate edDateTemplate = new EditDateTemplate(templates[e.RowIndex]);
         edDateTemplate.Show();
         dateChanged = true;
     }
     else if ((e.ColumnIndex == templateGridView.Columns["column6"].Index || e.ColumnIndex == templateGridView.Columns["column5"].Index) && e.RowIndex >= 0)
     {
         dateChanged = true;
     }
     else if (e.ColumnIndex == templateGridView.Columns["Column8"].Index && e.RowIndex >= 0)
     {
         if (templateGridView.Rows[e.RowIndex].Cells[4].Value.ToString().Equals("True") && templateGridView.Rows[e.RowIndex].Cells[5].Value == null)
         {
             MessageBox.Show("نوع دوره را مشخص کنید");
             return;
         }
         templates[e.RowIndex].Title = templateGridView.Rows[e.RowIndex].Cells[0].Value.ToString();
         if (templateGridView.Rows[e.RowIndex].Cells[3].Value.ToString().Equals("True"))
         {
             templates[e.RowIndex].IsAutomatic = true;
         }
         else
         {
             templates[e.RowIndex].IsAutomatic = false;
         }
         if (templateGridView.Rows[e.RowIndex].Cells[4].Value.ToString().Equals("True"))
         {
             templates[e.RowIndex].Periodic = true;
             if (templateGridView.Rows[e.RowIndex].Cells[5].Value.ToString().Equals("یک ماهه"))
             {
                 templates[e.RowIndex].PeriodType = 1;
             }
             else if (templateGridView.Rows[e.RowIndex].Cells[5].Value.ToString().Equals("سه ماهه"))
             {
                 templates[e.RowIndex].PeriodType = 2;
             }
             else if (templateGridView.Rows[e.RowIndex].Cells[5].Value.ToString().Equals("شش ماهه"))
             {
                 templates[e.RowIndex].PeriodType = 3;
             }
             else if (templateGridView.Rows[e.RowIndex].Cells[5].Value.ToString().Equals("یک ساله"))
             {
                 templates[e.RowIndex].PeriodType = 4;
             }
         }
         else
         {
             templates[e.RowIndex].Periodic   = false;
             templates[e.RowIndex].PeriodType = 0;
         }
         if (dateChanged)
         {
             Database.getDatabase().removeTemplateSentTimes(templates[e.RowIndex].id);
             Database.getDatabase().AddSentTimesToTemplate(templates[e.RowIndex]);
         }
         string query = "UPDATE templates SET title= '" + templates[e.RowIndex].Title + "', is_automatic= " + templates[e.RowIndex].IsAutomatic + ", is_periodic =" + templates[e.RowIndex].Periodic + ", period_type=" + templates[e.RowIndex].PeriodType + ", base_sent_time= '" + templates[e.RowIndex].SentTime.ToString("yyyy-MM-dd") + "' where template_id = " + templates[e.RowIndex].id;
         Database.getDatabase().Update(query);
         MessageBox.Show("تغییرات با موفقیت اعمال شد :)");
     }
 }
Пример #2
0
 private void templateGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == templateGridView.Columns["Column2"].Index && e.RowIndex >= 0)
     {
         EditTextTemplate edtexttemplate = new EditTextTemplate(templates[e.RowIndex]);
         edtexttemplate.Show();
     }
     else if (e.ColumnIndex == templateGridView.Columns["Column3"].Index && e.RowIndex >= 0)
     {
         EditReceiversOfTemplate editReceivers = new EditReceiversOfTemplate(templates[e.RowIndex].id);
         editReceivers.Show();
     }
     else if (e.ColumnIndex == templateGridView.Columns["Column7"].Index && e.RowIndex >= 0)
     {
         EditDateTemplate edDateTemplate = new EditDateTemplate(templates[e.RowIndex]);
         edDateTemplate.Show();
         dateChanged = true;
     }
     else if ((e.ColumnIndex == templateGridView.Columns["column6"].Index || e.ColumnIndex == templateGridView.Columns["column5"].Index) && e.RowIndex >= 0)
     {
         dateChanged = true;
     }
     else if (e.ColumnIndex == templateGridView.Columns["Column8"].Index && e.RowIndex >= 0)
     {
         if (templateGridView.Rows[e.RowIndex].Cells[4].Value.ToString().Equals("True") && templateGridView.Rows[e.RowIndex].Cells[5].Value == null)
         {
             MessageBox.Show("نوع دوره را مشخص کنید");
             return;
         }
         templates[e.RowIndex].Title = templateGridView.Rows[e.RowIndex].Cells[0].Value.ToString();
         if (templateGridView.Rows[e.RowIndex].Cells[3].Value.ToString().Equals("True"))
             templates[e.RowIndex].IsAutomatic = true;
         else
             templates[e.RowIndex].IsAutomatic = false;
         if (templateGridView.Rows[e.RowIndex].Cells[4].Value.ToString().Equals("True"))
         {
             templates[e.RowIndex].Periodic = true;
             if (templateGridView.Rows[e.RowIndex].Cells[5].Value.ToString().Equals("یک ماهه"))
                 templates[e.RowIndex].PeriodType = 1;
             else if (templateGridView.Rows[e.RowIndex].Cells[5].Value.ToString().Equals("سه ماهه"))
                 templates[e.RowIndex].PeriodType = 2;
             else if (templateGridView.Rows[e.RowIndex].Cells[5].Value.ToString().Equals("شش ماهه"))
                 templates[e.RowIndex].PeriodType = 3;
             else if (templateGridView.Rows[e.RowIndex].Cells[5].Value.ToString().Equals("یک ساله"))
                 templates[e.RowIndex].PeriodType = 4;
         }
         else
         {
             templates[e.RowIndex].Periodic = false;
             templates[e.RowIndex].PeriodType = 0;
         }
         if (dateChanged)
         {
             Database.getDatabase().removeTemplateSentTimes(templates[e.RowIndex].id);
             Database.getDatabase().AddSentTimesToTemplate(templates[e.RowIndex]);
         }
         string query = "UPDATE templates SET title= '" + templates[e.RowIndex].Title + "', is_automatic= " + templates[e.RowIndex].IsAutomatic + ", is_periodic =" + templates[e.RowIndex].Periodic + ", period_type=" + templates[e.RowIndex].PeriodType + ", base_sent_time= '" + templates[e.RowIndex].SentTime.ToString("yyyy-MM-dd") + "' where template_id = " + templates[e.RowIndex].id;
         Database.getDatabase().Update(query);
         MessageBox.Show("تغییرات با موفقیت اعمال شد :)");
     }
 }