コード例 #1
0
        private void registerButton_Click(object sender, EventArgs e)
        {
            string uname    = txtUser.Text;
            string password = txtPass.Text;
            string email    = txtEmail.Text;
            string name     = txtName.Text;

            if (string.IsNullOrEmpty(uname) ||
                string.IsNullOrEmpty(password) ||
                string.IsNullOrEmpty(email) ||
                string.IsNullOrEmpty(name))
            {
                MessageBox.Show("Error: Complete all the fields!");
            }
            else
            {
                _eduassistant     = new EducationAssistant(uname, password, email, name);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                Database.getDatabase().addUser(_eduassistant);
                MessageBox.Show("Count: " + Database.getDatabase().countOfUsers());
                txtUser.Text  = "";
                txtPass.Text  = "";
                txtEmail.Text = "";
                txtName.Text  = "";
                //this.Close();
            }
        }
コード例 #2
0
        private void btnAddReciever_Click(object sender, EventArgs e)
        {
            string fName = txtFName.Text;
            string lName = txtLName.Text;
            string email = txtEmail.Text;
            string role  = "";

            //MessageBox.Show(optionRole.Text);
            if (optionRole.Text.Equals("دانشجو"))
            {
                role = "student";
            }
            else
            {
                role = "professor";
            }

            if (string.IsNullOrEmpty(fName) ||
                string.IsNullOrEmpty(lName) ||
                string.IsNullOrEmpty(email) ||
                string.IsNullOrEmpty(role))
            {
                MessageBox.Show("خطا: تمام قسمت ها را پر کنید.");
            }
            else
            {
                _receiver         = new Receiver(fName, lName, email, role);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                Database.getDatabase().AddReciever(_receiver);
                MessageBox.Show("مخاطب اضافه شد!");
            }
        }
コード例 #3
0
        public EditReceiversOfTemplate(int id)
        {
            InitializeComponent();
            template_id           = id;
            groups                = Database.getDatabase().getReceiverGroups();
            Oldselected_groups    = Database.getDatabase().getGroupsOfTemplate(template_id);
            Oldselected_receivers = Database.getDatabase().getReceiversOfTemplate(template_id);
            Newselected_groups    = new List <ReceiverGroup>();
            Newselected_receivers = new List <Receiver>();
            receivers             = null;
            for (int i = 0; i < groups.Count; i++)
            {
                GroupsDropDown.Items.Add(groups[i].title);
            }

            for (int i = 0; i < Oldselected_groups.Count; i++)
            {
                Newselected_groups.Add(Oldselected_groups[i]);
                listBox1.Items.Add(Oldselected_groups[i].title);
            }
            for (int i = 0; i < Oldselected_receivers.Count; i++)
            {
                Newselected_receivers.Add(Oldselected_receivers[i]);
                listBox2.Items.Add(Oldselected_receivers[i].FName + " " + Oldselected_receivers[i].LName);
            }
        }
コード例 #4
0
 private void AddReceiversToGroup_Load(object sender, EventArgs e)
 {
     receivers = Database.getDatabase().getReceivers();
     for (int i = 0; i < receivers.Count; i++)
     {
         ReceiversDropDown.Items.Add(receivers[i].FName + " " + receivers[i].LName);
     }
     this.listBox1.MouseDoubleClick += new MouseEventHandler(listBox1_MouseDoubleClick);
 }
コード例 #5
0
        private void MakeGroup_Load(object sender, EventArgs e)
        {
            groups = Database.getDatabase().getReceiverGroups();

            for (int i = 0; i < groups.Count; i++)
            {
                root_group.Items.Add(groups[i].title);
            }
        }
コード例 #6
0
 public AddReceiversToGroup(int id)
 {
     InitializeComponent();
     this.group_id       = id;
     NewreceiversOfGroup = new List <Receiver>();
     OldreceiversOfGroup = Database.getDatabase().GetReceiversOfGroup(group_id);
     for (int i = 0; i < OldreceiversOfGroup.Count; i++)
     {
         listBox1.Items.Add(OldreceiversOfGroup[i].FName + " " + OldreceiversOfGroup[i].LName);
         NewreceiversOfGroup.Add(OldreceiversOfGroup[i]);
     }
 }
コード例 #7
0
        private void CreateTemplate_Load(object sender, EventArgs e)
        {
            groups = Database.getDatabase().getReceiverGroups();


            for (int i = 0; i < groups.Count; i++)
            {
                GroupsDropDown.Items.Add(groups[i].title);
            }

            this.listBox1.MouseDoubleClick += new MouseEventHandler(listBox1_MouseDoubleClick);
            this.listBox2.MouseDoubleClick += new MouseEventHandler(listBox2_MouseDoubleClick);
        }
コード例 #8
0
        private void GroupsDropDown_SelectedIndexChanged(object sender, EventArgs e)
        {
            selectedGroup = groups[GroupsDropDown.SelectedIndex];
            receivers     = Database.getDatabase().GetReceiversOfGroup(selectedGroup.id);
            if (ReceiversDropDown.Items.Count > 0)
            {
                ReceiversDropDown.Items.Clear();
            }

            for (int i = 0; i < receivers.Count; i++)
            {
                ReceiversDropDown.Items.Add(receivers[i].FName + " " + receivers[i].LName);
            }
        }
コード例 #9
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if ((Database.getDatabase().IsRegistered(txtUser.Text, txtPass.Text)))
     {
         MessageBox.Show("شما وارد شدید!");
         Home home = new Home();
         home.Show();
         this.Close();
     }
     else
     {
         MessageBox.Show("نام کاربری یا کلمه عبور اشتباه است");
     }
 }
コード例 #10
0
        private void button2_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < NewreceiversOfGroup.Count; i++)
            {
                bool existed = false;
                for (int j = 0; j < OldreceiversOfGroup.Count; j++)
                {
                    if (NewreceiversOfGroup[i].ID == OldreceiversOfGroup[j].ID)
                    {
                        existed = true;
                        break;
                    }
                }
                if (existed)
                {
                    continue;
                }
                Database.getDatabase().AddReceiverToGroup(group_id, NewreceiversOfGroup[i].ID);
            }
            for (int i = 0; i < OldreceiversOfGroup.Count; i++)
            {
                bool deleted = true;
                for (int j = 0; j < NewreceiversOfGroup.Count; j++)
                {
                    if (OldreceiversOfGroup[i].ID == NewreceiversOfGroup[j].ID)
                    {
                        deleted = false;
                        break;
                    }
                }
                if (deleted)
                {
                    Database.getDatabase().removeReceiverOfGroup(OldreceiversOfGroup[i].ID, group_id);
                }
            }
            this.Close();

            //Database.getDatabase().AddReceiverToGroup(group_id,receiver_id);
        }
コード例 #11
0
        private void btnMakeGroup_Click(object sender, EventArgs e)
        {
            string title       = txtTitle.Text;
            string description = txtDescription.Text;

            if (string.IsNullOrEmpty(title) ||
                string.IsNullOrEmpty(description))
            {
                MessageBox.Show("خطا: تمام قسمت ها را پر کنید.");
            }
            else
            {
                int root_index = 0;
                if (root_group.SelectedIndex != -1)
                {
                    root_index = groups[root_group.SelectedIndex].id;
                }

                _group            = new ReceiverGroup(1, title, description, root_index);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                Database.getDatabase().AddRecieverGroup(_group);
                MessageBox.Show("گروه اضافه شد!");
            }
        }
コード例 #12
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("تغییرات با موفقیت اعمال شد :)");
     }
 }
コード例 #13
0
 public ShowTemplates()
 {
     InitializeComponent();
     templates   = Database.getDatabase().getTemplates();
     dateChanged = false;
 }
コード例 #14
0
 private void button2_Click(object sender, EventArgs e)
 {
     //adding new receivers
     for (int i = 0; i < Newselected_receivers.Count; i++)
     {
         bool existed = false;
         for (int j = 0; j < Oldselected_receivers.Count; j++)
         {
             if (Newselected_receivers[i].ID == Oldselected_receivers[j].ID)
             {
                 existed = true;
                 break;
             }
         }
         if (existed)
         {
             continue;
         }
         Database.getDatabase().AddReceiverToTemplate(Newselected_receivers[i].ID, template_id);
     }
     //removing deleted receivers
     for (int i = 0; i < Oldselected_receivers.Count; i++)
     {
         bool deleted = true;
         for (int j = 0; j < Newselected_receivers.Count; j++)
         {
             if (Oldselected_receivers[i].ID == Newselected_receivers[j].ID)
             {
                 deleted = false;
                 break;
             }
         }
         if (deleted)
         {
             Database.getDatabase().removeReceiverOfTemplate(Oldselected_receivers[i].ID, template_id);
         }
     }
     //adding new groups
     for (int i = 0; i < Newselected_groups.Count; i++)
     {
         bool existed = false;
         for (int j = 0; j < Oldselected_groups.Count; j++)
         {
             if (Newselected_groups[i].id == Oldselected_groups[j].id)
             {
                 existed = true;
                 break;
             }
         }
         if (existed)
         {
             continue;
         }
         Database.getDatabase().AddGroupToTemplate(Newselected_groups[i].id, template_id);
     }
     //removing deleted groups
     for (int i = 0; i < Oldselected_groups.Count; i++)
     {
         bool deleted = true;
         for (int j = 0; j < Newselected_groups.Count; j++)
         {
             if (Oldselected_groups[i].id == Newselected_groups[j].id)
             {
                 deleted = false;
                 break;
             }
         }
         if (deleted)
         {
             Database.getDatabase().removeGroupOfTemplate(Oldselected_groups[i].id, template_id);
         }
     }
     this.Close();
 }
コード例 #15
0
        private void btnCreateTemp_Click(object sender, EventArgs e)
        {
            string   title       = txtTitle.Text;
            string   text        = txtText.Text;
            string   receivers   = "";
            DateTime senttime    = dtsenttime.Value;
            bool     periodic    = false;
            bool     isAutomatic = false;
            bool     error       = false;
            int      type        = 0;

            if (YesToPeriodic.Checked)
            {
                periodic = true;
            }
            else if (NoToPeriodic.Checked)
            {
                periodic = false;
            }
            else
            {
                error = true;
            }
            if (YesToAutomatic.Checked)
            {
                isAutomatic = true;
            }
            else if (NoToAutomatic.Checked)
            {
                isAutomatic = false;
            }
            else
            {
                error = true;
            }
            if (periodic)
            {
                if (month1.Checked)
                {
                    type = 1;
                }
                else if (month3.Checked)
                {
                    type = 2;
                }
                else if (month6.Checked)
                {
                    type = 3;
                }
                else if (year.Checked)
                {
                    type = 4;
                }
                else
                {
                    error = true;
                }
            }
            else
            {
                type = 0;
            }

            if (string.IsNullOrEmpty(title) ||
                string.IsNullOrEmpty(text) ||
                error)
            {
                MessageBox.Show("خطا: تمام قسمت ها را پر کنید.");
            }
            else
            {
                _template         = new Template(1, title, text, periodic, senttime, isAutomatic, type);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                Database.getDatabase().AddTemplate(_template, selected_groups, selected_receivers);


                MessageBox.Show("قالب با موفقیت اضافه شد");
                this.Close();
            }
        }
コード例 #16
0
 public ShowReceiverGroups()
 {
     InitializeComponent();
     groups = Database.getDatabase().getReceiverGroups();
     RefreshList();
 }