Пример #1
0
        private void signup_btn_Click(object sender, EventArgs e)
        {
            if (isCB.Checked)
            {
                if (datasourceTxt.Text == "")
                {
                    datasourceerrorlabel.Visible = true;
                }
                else
                {
                    datasourceerrorlabel.Visible = false;
                };
                if (dbsTxt.Text == "")
                {
                    dbserrorlabel.Visible = true;
                }
                else
                {
                    dbserrorlabel.Visible = false;
                };
                if (datasourceerrorlabel.Visible || dbserrorlabel.Visible)
                {
                    MessageBox.Show("Fields with * are mandatory");
                }
                else
                {
                    sb.Append("DataSource= " + datasourceTxt + "; Initial Catalog= " + dbsTxt + "; Integrated Security= true; MultipleActiveResultSets=true");
                    File.WriteAllText(MainClass.path + "\\eduvation", sb.ToString());
                    DialogResult dr = MessageBox.Show("Sign Up Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (dr == DialogResult.OK)
                    {
                        Login Log = new Login();
                        MainClass.ShowWindow(Log, this, MDI.ActiveForm);
                    }
                }
            }
            else
            {
                if (datasourceTxt.Text == "")
                {
                    datasourceerrorlabel.Visible = true;
                }
                else
                {
                    datasourceerrorlabel.Visible = false;
                };
                if (dbsTxt.Text == "")
                {
                    dbserrorlabel.Visible = true;
                }
                else
                {
                    dbserrorlabel.Visible = false;
                };
                if (usernameTxt.Text == "")
                {
                    usernameerrorlabel.Visible = true;
                }
                else
                {
                    usernameerrorlabel.Visible = false;
                };
                if (passwordTxt.Text == "")
                {
                    passworderrorlabel.Visible = true;
                }
                else
                {
                    passworderrorlabel.Visible = false;
                };
                if (datasourceerrorlabel.Visible || dbserrorlabel.Visible || usernameerrorlabel.Visible || passworderrorlabel.Visible)
                {
                    MessageBox.Show("Fields with * are mandatory");
                }
                else
                {
                    sb.Append("DataSource= " + datasourceTxt.Text + "; Initial Catalog= " + dbsTxt.Text + "; User ID= " + usernameTxt.Text + "; Password= "******"; MultipleActiveResultSets=true");
                    File.WriteAllText(MainClass.path + "\\eduvation", sb.ToString());
                    DialogResult dr = MessageBox.Show("Sign Up Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (dr == DialogResult.OK)
                    {
                        Login Log = new Login();
                        MainClass.ShowWindow(Log, this, MDI.ActiveForm);
                    }
                }
            }
        }
Пример #2
0
        public override void save_btn_Click(object sender, EventArgs e)
        {
            if (standardNameTxt.Text == "")
            {
                standardnameerror_Label.Visible = true;
            }
            else
            {
                standardnameerror_Label.Visible = false;
            }
            if (statusDD.SelectedIndex == -1)
            {
                statuserror_label.Visible = true;
            }
            else
            {
                statuserror_label.Visible = false;
            }

            //Now We made a condition if any of error label is visible it will show a message dialog
            if (standardnameerror_Label.Visible || statuserror_label.Visible)
            {
                MainClass.MSGBox("Fields with * are mandatory", "ERROR!!", "Error");
            }
            else
            {
                if (edit == 0) //Code For SAVE
                {
                    //here the table is come up as a class because we use LINQ method
                    classes c = new classes();

                    if (statusDD.SelectedIndex == 0)
                    {
                        c.cls_status = 1; //For Active
                    }
                    else
                    {
                        c.cls_status = 0; //For Inactive
                    }
                    eduvationdb.st_insertClass(standardNameTxt.Text, c.cls_status);
                    //Without this class you could not submit the changes to dbs so it is necessary
                    eduvationdb.SubmitChanges();

                    MainClass.MSGBox(standardNameTxt.Text + " Added Successfully.", "Success", "Success");
                    MainClass.reset_disable(panel6);
                    loadData();
                }
                else if (edit == 1) //Code For UPDATE
                {
                    //here the table is come up as a class because we use LINQ method
                    byte status;
                    if (statusDD.SelectedIndex == 0)
                    {
                        status = 1; //For Active
                    }
                    else
                    {
                        status = 0; //For Inactive
                    }
                    eduvationdb.st_updateClass(standardNameTxt.Text, status, classID);
                    //Without this class you could not submit the changes to dbs so it is necessary
                    eduvationdb.SubmitChanges();

                    MainClass.MSGBox(standardNameTxt.Text + " Updated Successfully.", "Success", "Success");
                    MainClass.reset_disable(panel6);
                    loadData();
                }
            }
        }
Пример #3
0
 //Here We override the methods from sample 2 form
 public override void add_btn_Click(object sender, EventArgs e)
 {
     MainClass.reset_enable(panel6);
     edit = 0;
 }
Пример #4
0
 public override void edit_btn_Click(object sender, EventArgs e)
 {
     edit = 1;
     MainClass.Enable(panel6);
 }
Пример #5
0
 private void Classes_Load(object sender, EventArgs e)
 {
     MainClass.reset_disable(panel6);
 }