private void btnpasssave_Click(object sender, EventArgs e)
        {
            var pass = db.UserLogins.Where(c => c.UserName == FormLogin.USERNAME).FirstOrDefault();

            if (pass.Password == textBoxpass.Text)
            {
                if (textBoxnewpass.Text != "")
                {
                    if (textBoxnewpass.Text == textBoxcpass.Text)
                    {
                        pass.Password        = textBoxnewpass.Text;
                        db.Entry(pass).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        MessageBox.Show("Password successfully changed!", "Data Updated - Student Management Sytem", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        DbEntityRefresh.Refresh(db);
                        FormMain_Shown(sender, e);
                    }
                    else
                    {
                        MessageBox.Show("New Password and Confirm Password does not match!", "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a new password!", "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("You have entered an incorrect current password!", "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void panelsearchprevious_Click(object sender, EventArgs e)
        {
            DbEntityRefresh.Refresh(db);
            PreviousStudentList lst = new PreviousStudentList();

            lst.ShowDialog();
        }
        private void btnschoolsave_Click(object sender, EventArgs e)
        {
            try
            {
                var schooladress  = db.Randoms.Where(c => c.ID == 2).FirstOrDefault();
                var schoolemail   = db.Randoms.Where(c => c.ID == 4).FirstOrDefault();
                var schoolcontact = db.Randoms.Where(c => c.ID == 3).FirstOrDefault();

                schooladress.Text  = txtschooladdress.Text;
                schoolcontact.Text = txtschoolcontact.Text;
                schoolemail.Text   = txtschoolemail.Text;

                db.Entry(schooladress).State  = System.Data.Entity.EntityState.Modified;
                db.Entry(schoolemail).State   = System.Data.Entity.EntityState.Modified;
                db.Entry(schoolcontact).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                MessageBox.Show("Your School Data is sucessfully updated", "Data Updated - Student Management Sytem", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                DbEntityRefresh.Refresh(db);
                FormMain_Shown(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An Error Occured: " + ex.Message.ToString(), "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnusersave_Click(object sender, EventArgs e)
        {
            var user = db.UserLogins.Where(c => c.UserName == textBoxuser.Text).FirstOrDefault();

            if (user != null)
            {
                if (textBoxnewuser.Text != "")
                {
                    if (textBoxnewuser.Text == textBoxcuser.Text)
                    {
                        user.UserName        = textBoxnewuser.Text;
                        db.Entry(user).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        MessageBox.Show("Username successfully changed!", "Data Updated - Student Management Sytem", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        DbEntityRefresh.Refresh(db);
                        FormMain_Shown(sender, e);
                    }
                    else
                    {
                        MessageBox.Show("New Username and Confirm Username does not match!", "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a new username!", "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("You have entered an incorrect current username!", "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #5
0
        private void Bwreg_DoWork(object sender, DoWorkEventArgs e)
        {
            DbEntityRefresh.Refresh(db);

            LicenseEntity licdb = new LicenseEntity();

            try
            {
                var a = licdb.Licenses.Where(c => c.SoftwareID == txtpublickey.Text).FirstOrDefault();
                if (a != null)
                {
                    var  uid        = db.Randoms.Where(c => c.ID == 18).FirstOrDefault();
                    bool IsPayement = a.IsPayment;
                    if (IsPayement)
                    {
                        if (txtlicense.Text == a.LicenseKey)
                        {
                            var path = Application.StartupPath + @"\bin\";

                            string filename = "License.lic";

                            string[] lines = File.ReadAllLines(path + filename);

                            string ency = a.LicenseStarts + "," + a.LicenseEnds + "," + uid.Text + "," + a.OwnerName + "," + a.SchoolName + "," + "False";

                            lines[7] = "Licensed Hash:" + ClsTripleDES.Encrypt(ency);

                            File.WriteAllLines(path + "/" + filename, lines);

                            a.InProcess = false;

                            licdb.Entry(a).State = System.Data.Entity.EntityState.Modified;
                            licdb.SaveChanges();

                            validate = true;
                        }
                        MessageBox.Show("Student Management System is successfully activated until " + a.LicenseEnds, "Successfully Activated", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }

                    else
                    {
                        validate = false;
                    }
                }
                else
                {
                    MessageBox.Show("Your request doesnot exist at our License server! Please send request then register!", "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured: " + ex.Message.ToString(), "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                licdb.Dispose();
            }
        }
Exemple #6
0
        private void Bwreq_DoWork(object sender, DoWorkEventArgs e)
        {
            LicenseEntity licdb = new LicenseEntity();

            try
            {
                DbEntityRefresh.Refresh(db);

                if (RequestExists())
                {
                    req = false;
                    MessageBox.Show("Please be patience! Your request is under proces!", "Error - Student Management Sytem", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    SoftwareIDCheck(txtpublickey.Text);
                    var     schoolname = db.Randoms.Where(c => c.ID == 1).FirstOrDefault();
                    var     Address    = db.Randoms.Where(c => c.ID == 2).FirstOrDefault();
                    var     Contact    = db.Randoms.Where(c => c.ID == 3).FirstOrDefault();
                    var     Email      = db.Randoms.Where(c => c.ID == 4).FirstOrDefault();
                    var     OwnerName  = db.Randoms.Where(c => c.ID == 5).FirstOrDefault();
                    var     softid     = db.Randoms.Where(c => c.ID == 18).FirstOrDefault();
                    License lic        = new License()
                    {
                        SoftwareID      = softid.Text.ToString().Substring(0, 18),
                        SchoolName      = schoolname.Text,
                        SchoolAddress   = Address.Text,
                        SchoolContact   = Contact.Text,
                        SchoolEmail     = Email.Text,
                        OwnerName       = OwnerName.Text,
                        IstallationDate = InstallationDate().ToString(),
                        InProcess       = true,
                        IsPayment       = false,
                        LicenseKey      = LicenseKey(),
                        LicenseStarts   = LicenseStarts(),
                        LicenseEnds     = LicenseEnds()
                    };

                    licdb.Licenses.Add(lic);
                    licdb.SaveChanges();
                    req = true;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message.ToString(), "Error - Student Management Sytem", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            finally
            {
                licdb.Dispose();
            }
        }
        private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            DbEntityRefresh.Refresh(db);


            li = db.StudentDatas.ToList();
            labeltotalstd.Text = li.Count.ToString();

            fe = db.StudentFees.Where(c => c.Submitted == false).ToList();
            labeltotalfeede.Text = fe.Count.ToString();


            labelfee.Text = "RS." + TotalAmountPerMonth() + "/-";

            switch (tabControl.SelectedIndex)
            {
            case 0:
                this.btndashbaord.Normalcolor = System.Drawing.Color.FromArgb(((int)(((byte)(157)))), ((int)(((byte)(128)))), ((int)(((byte)(159)))));
                this.btnstudent.Normalcolor   = Color.Transparent;
                this.btnfees.Normalcolor      = Color.Transparent;
                this.btnsetting.Normalcolor   = Color.Transparent;
                this.btnabout.Normalcolor     = Color.Transparent;
                this.btnsetting.Normalcolor   = Color.Transparent;
                break;

            case 1:
                this.btnstudent.Normalcolor   = System.Drawing.Color.FromArgb(((int)(((byte)(157)))), ((int)(((byte)(128)))), ((int)(((byte)(159)))));
                this.btndashbaord.Normalcolor = Color.Transparent;
                this.btnfees.Normalcolor      = Color.Transparent;
                this.btnsetting.Normalcolor   = Color.Transparent;
                this.btnabout.Normalcolor     = Color.Transparent;
                this.btnsetting.Normalcolor   = Color.Transparent;
                break;

            case 2:
                this.btnstudent.Normalcolor   = Color.Transparent;
                this.btndashbaord.Normalcolor = Color.Transparent;
                this.btnfees.Normalcolor      = System.Drawing.Color.FromArgb(((int)(((byte)(157)))), ((int)(((byte)(128)))), ((int)(((byte)(159)))));
                this.btnsetting.Normalcolor   = Color.Transparent;
                this.btnabout.Normalcolor     = Color.Transparent;
                this.btnsetting.Normalcolor   = Color.Transparent;
                break;

            case 3:
                this.btnstudent.Normalcolor   = Color.Transparent;
                this.btndashbaord.Normalcolor = Color.Transparent;
                this.btnfees.Normalcolor      = Color.Transparent;
                this.btnsetting.Normalcolor   = Color.Transparent;
                this.btnabout.Normalcolor     = System.Drawing.Color.FromArgb(((int)(((byte)(157)))), ((int)(((byte)(128)))), ((int)(((byte)(159)))));
                this.btnsetting.Normalcolor   = Color.Transparent;
                break;
            }
        }
        private void btnprintersave_Click(object sender, EventArgs e)
        {
            string filename = Application.StartupPath + @"\bin\User.config";

            string[] lines = File.ReadAllLines(filename);

            lines[3] = "DefaultPrinter:" + comboboxprinters.Text;

            File.WriteAllLines(filename, lines);

            MessageBox.Show("Your Default printer is successfully changed. \nDefault Printer Name:" + comboboxprinters.Text, "Success - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            DbEntityRefresh.Refresh(db);
            FormMain_Shown(sender, e);
        }
Exemple #9
0
        private void Restore()
        {
            System.Threading.Thread.Sleep(5000);


            DbEntities newdb = new DbEntities();

            DbEntityRefresh.Refresh(newdb);
            try
            {
                sourcepath = txtfilename.Text;
                File.Move(sourcepath, Path.ChangeExtension(sourcepath, ".db"));

                if (File.Exists(destpath + "/Database.db"))
                {
                    File.Delete(destpath + "/Database.db");
                }

                File.Copy(Path.GetDirectoryName(sourcepath) + "/Database.db", destpath + "/Database.db");

                File.Move(Path.GetDirectoryName(sourcepath) + "/Database.db", Path.ChangeExtension(Path.GetDirectoryName(sourcepath) + "/Database.db", ".backupsms"));

                var schoolname    = newdb.Randoms.Where(c => c.ID == 1).FirstOrDefault();
                var schooladdress = newdb.Randoms.Where(c => c.ID == 2).FirstOrDefault();
                var schoolcontact = newdb.Randoms.Where(c => c.ID == 3).FirstOrDefault();
                var schoolemail   = newdb.Randoms.Where(c => c.ID == 4).FirstOrDefault();
                var ownername     = newdb.Randoms.Where(c => c.ID == 5).FirstOrDefault();
                var softid        = newdb.Randoms.Where(c => c.ID == 18).FirstOrDefault();

                string fileName = Application.StartupPath + @"\bin\License.lic";


                // Check if file already exists. If yes, delete it.
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                // Create a new file
                using (StreamWriter sw = File.CreateText(fileName))
                {
                    sw.WriteLine("Owner Name:" + ownername.Text);
                    sw.WriteLine("School Name:" + schoolname.Text);
                    sw.WriteLine("School Address:" + schooladdress.Text);
                    sw.WriteLine("School Contact:" + schoolcontact.Text);
                    sw.WriteLine("School Email:" + schoolemail.Text);
                    sw.WriteLine("Installation Date:" + DateTime.Now.ToString("dd/MM/yyyy"));
                    sw.WriteLine("IsActivated:" + ClsTripleDES.Encrypt("False"));
                    string ency = DateTime.Now.ToString("dd/MM/yyyy") + "," + DateTime.Now.AddDays(5).ToString("dd/MM/yyyy") + "," + softid.Text + "," + ownername.Text + "," + schoolname.Text + "," + "True";
                    sw.WriteLine("Licensed Hash:" + ClsTripleDES.Encrypt(ency));
                }

                string[] lines = File.ReadAllLines(Application.StartupPath + @"\bin\User.Config");
                lines[0] = "Owner Name:" + txtowner.Text;
                lines[1] = "School Name:" + txtschoolname.Text;
                lines[2] = "FirstRun:" + "False";
                lines[3] = "DefaultPrinter:null";

                File.WriteAllLines(Application.StartupPath + @"\bin\User.Config", lines);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                newdb.Dispose();
            }
        }
 private void FeeSetting_Activated(object sender, EventArgs e)
 {
     DbEntityRefresh.Refresh(db);
     FeeSetting_Load(sender, e);
 }
 private void FormMain_Activated(object sender, EventArgs e)
 {
     DbEntityRefresh.Refresh(db);
 }
 private void FormMain_Activated(object sender, EventArgs e)
 {
     DbEntityRefresh.Refresh(db);
     LicenseInformation();
     FormMain_Shown(sender, e);
 }
Exemple #13
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            if (job)
            {
                string mode = "";

                if (checkBoxGraduated.Checked)
                {
                    mode = "Graduated";
                }

                if (checkBoxstruckoff.Checked)
                {
                    mode = "Struck Off";
                }

                DateTime date = Convert.ToDateTime(Admitdatepicker.Value);
                try
                {
                    var data    = db.StudentDatas.Where(c => c.ID == ID).FirstOrDefault();
                    var profile = db.StudentProfiles.Where(c => c.ID == ID).FirstOrDefault();
                    var fee     = db.StudentFees.Where(c => c.ID == ID).FirstOrDefault();

                    PreStudent students = new PreStudent()
                    {
                        StudentID     = ID,
                        StudentName   = StudentName,
                        FatherName    = data.FatherName,
                        MotherName    = data.MotherName,
                        RegNo         = data.RegNo,
                        DateOfBirth   = data.DateOfBirth,
                        PlaceOfBirth  = data.PlaceOfBirth,
                        NIC           = data.NIC,
                        Gender        = data.Gender,
                        Religion      = data.Religion,
                        Address       = data.Address,
                        Contact       = data.Contact,
                        Class         = data.Class,
                        Section       = data.Section,
                        AdmitDate     = data.AdmitDate,
                        Session       = data.Session,
                        Mode          = mode,
                        StruckOffDate = date.ToString("dd/MM/yyyy")
                    };

                    db.Entry(data).State    = System.Data.Entity.EntityState.Deleted;
                    db.Entry(fee).State     = System.Data.Entity.EntityState.Deleted;
                    db.Entry(profile).State = System.Data.Entity.EntityState.Deleted;
                    db.PreviousStudents.Add(students);
                    db.SaveChanges();

                    DbEntityRefresh.Refresh(db);

                    labelresult.Text      = "Successfully Saved!";
                    labelresult.ForeColor = Color.Green;
                    labelresult.Visible   = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occured: " + ex.Message.ToString(), "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void btngenerate_Click(object sender, EventArgs e)
        {
            try
            {
                DbEntityRefresh.Refresh(db);
                var check = db.StudentDatas.Where(c => c.Class == comboboxclass.Text && c.Section == comboboxsection.Text).FirstOrDefault();
                if (check != null)
                {
                    foreach (var item in db.StudentDatas.Where(c => c.Class == comboboxclass.Text && c.Section == comboboxsection.Text))
                    {
                        IDarrayList.Add(item.ID);
                    }


                    var cls       = db.Randoms.Where(c => c.ID == 6).FirstOrDefault();
                    var clasarray = cls.Text.Split(',');

                    for (int i = 0; i <= clasarray.Length - 1; i++)
                    {
                        if (comboboxclass.Text == clasarray[i])
                        {
                            index = i;
                            break;
                        }
                    }

                    currentclass = clasarray[index].ToString();
                    if (clasarray.Length > (index + 1))
                    {
                        nextclass = clasarray[index + 1].ToString();
                    }

                    var fee      = db.Randoms.Where(x => x.ID == 8).FirstOrDefault();
                    var feearray = fee.Text.Split(';');

                    var    feearray1 = feearray[index + 1].ToString().Split(',');
                    string fees      = feearray1[0].ToString() + "," + feearray1[0].ToString() + "," + feearray1[0].ToString() + "," + feearray1[0].ToString() + "," + feearray1[0].ToString() + "," + feearray1[0].ToString() + "," + feearray1[0].ToString() + "," + feearray1[0].ToString() + "," + feearray1[0].ToString() + "," + feearray1[0].ToString() + "," + feearray1[0].ToString() + "," + feearray1[0].ToString();



                    for (int i = 0; i <= IDarrayList.ToArray().Length - 1; i++)
                    {
                        int id     = Convert.ToInt32(IDarrayList[i].ToString());
                        var data   = db.StudentDatas.Where(c => c.ID == id).FirstOrDefault();
                        var stdfee = db.StudentFees.Where(c => c.ID == id).FirstOrDefault();

                        data.Class     = nextclass;
                        data.Fees      = fees;
                        stdfee.ExamFee = Convert.ToInt32(feearray1[1].ToString());

                        db.Entry(data).State = System.Data.Entity.EntityState.Modified;

                        db.Entry(stdfee).State = System.Data.Entity.EntityState.Modified;
                    }

                    db.SaveChanges();
                    MessageBox.Show("Report of class: " + comboboxclass.Text + " " + comboboxsection.Text + " submitted successfully!", "Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    MessageBox.Show("Sorry! No record found with this class!", "Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An Error Occured: " + ex.Message.ToString(), "Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void AnnualReport_Activated(object sender, EventArgs e)
 {
     DbEntityRefresh.Refresh(db);
 }