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 btnsaveclass_Click(object sender, EventArgs e)
        {
            ArrayList classList    = new ArrayList();
            ArrayList feearrayList = new ArrayList();

            var clas = db.Randoms.Where(c => c.ID == 26).FirstOrDefault();
            var fee  = db.Randoms.Where(c => c.ID == 32).FirstOrDefault();

            feearrayList.AddRange(fee.Text.Split(';'));

            for (int i = 0; i <= 15; i++)
            {
                string             className = "txtclass" + (i + 1).ToString();
                BunifuMetroTextbox lbl_text  = this.Controls.Find(className, true).FirstOrDefault() as BunifuMetroTextbox;

                if (lbl_text.Text != "")
                {
                    classList.Add(lbl_text.Text);
                }
            }

            string classess    = String.Join(",", classList.ToArray());
            int    classlength = classList.ToArray().Length;

            int feelength = feearrayList.ToArray().Length;


            int min = classlength - feelength;

            for (int i = 1; i <= min; i++)
            {
                feearrayList.Add("0,0");
            }

            string finalfee = String.Join(";", feearrayList.ToArray());

            try
            {
                clas.Text            = classess;
                fee.Text             = finalfee;
                db.Entry(clas).State = System.Data.Entity.EntityState.Modified;
                db.Entry(fee).State  = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                labelresult.Text      = ex.Message.ToString();
                labelresult.Visible   = true;
                labelresult.ForeColor = Color.Red;
            }
            finally
            {
                labelresult.Text      = "Saved Successfully!";
                labelresult.Visible   = true;
                labelresult.ForeColor = Color.Green;
            }
        }
示例#3
0
 private void btnmodify_Click(object sender, EventArgs e)
 {
     if (STUDENT_ID != 0 && STUDENT_ID > 0)
     {
         if (MessageBox.Show("Are you sure you want to delete record with:\n ID: " + STUDENT_ID + " & Name: " + StudentName + "?", "Confirmation - Studnet Management System", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
         {
             try
             {
                 var i = db.StudentDatas.Where(c => c.ID == STUDENT_ID).FirstOrDefault();
                 var j = db.StudentProfiles.Where(d => d.ID == STUDENT_ID).FirstOrDefault();
                 db.Entry(i).State = System.Data.Entity.EntityState.Deleted;
                 db.Entry(j).State = System.Data.Entity.EntityState.Deleted;
                 db.SaveChanges();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             finally
             {
                 db.Dispose();
                 MessageBox.Show("Record deleted successfully with ID: " + STUDENT_ID + " & Name: " + name, "Error", MessageBoxButtons.OK);
             }
         }
     }
 }
        private void btnsave_Click(object sender, EventArgs e)
        {
            var det = db.StudentDatas.Where(c => c.ID == FeeSetting.STUDENT_ID).FirstOrDefault();

            det.Fees = txttution.Text + "," + txttution.Text + "," + txttution.Text + "," + txttution.Text + "," + txttution.Text + "," + txttution.Text + "," + txttution.Text + "," + txttution.Text + "," + txttution.Text + "," + txttution.Text + "," + txttution.Text + "," + txttution.Text;

            var fees = db.StudentFees.Where(c => c.ID == FeeSetting.STUDENT_ID).FirstOrDefault();

            fees.TransportFee = Convert.ToInt32(txttransport.Text);
            fees.ExamFee      = Convert.ToInt32(txtexam.Text);
            fees.OthersFee    = Convert.ToInt32(txtother.Text);

            try
            {
                db.Entry(det).State  = System.Data.Entity.EntityState.Modified;
                db.Entry(fees).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                labelresult.Text      = ex.Message.ToString();
                labelresult.Visible   = true;
                labelresult.ForeColor = Color.Red;
            }
            finally
            {
                labelresult.Text      = "Successfully Saved!";
                labelresult.Visible   = true;
                labelresult.ForeColor = Color.Green;
            }
        }
        private void btnsave_Click(object sender, EventArgs e)
        {
            if (txtstdname.Text != null && txtstdname.Text != "" && txtathername.Text != null && txtathername.Text != "" && txtregno.Text != null && txtregno.Text != "" &&
                txtmothername.Text != null && txtmothername.Text != "" && DateofBirthPicker.Text != null && DateofBirthPicker.Text != "" && txtaddress.Text != null && txtaddress.Text != "" &&
                txtplaceofbirth.Text != null && txtplaceofbirth.Text != "" && txtcnic.Text != null && txtcnic.Text != "" &&
                ComboBoxGender.Text != null && ComboBoxGender.Text != "" && txtreligion.Text != null && txtreligion.Text != "" &&
                txtcontact.Text != null && txtcontact.Text != "" && comboboxclass.Text != null && comboboxclass.Text != "" &&
                comboboxsection.Text != null && comboboxsection.Text != "" && Admitdatepicker.Text != null && Admitdatepicker.Text != "")
            {
                try
                {
                    var i = db.StudentDatas.Where(c => c.ID == ModifyStudent.STUDENT_ID).FirstOrDefault();
                    var j = db.StudentProfiles.Where(d => d.ID == ModifyStudent.STUDENT_ID).FirstOrDefault();
                    i.StudentName  = txtstdname.Text;
                    i.FatherName   = txtathername.Text;
                    i.RegNo        = txtregno.Text;
                    i.MotherName   = txtmothername.Text;
                    i.DateOfBirth  = DateofBirthPicker.Value.ToString();
                    i.PlaceOfBirth = txtplaceofbirth.Text;
                    i.Address      = txtaddress.Text;
                    i.NIC          = txtcnic.Text;
                    i.Gender       = ComboBoxGender.Text;
                    i.Religion     = txtreligion.Text;
                    i.Contact      = txtcontact.Text;
                    i.Class        = comboboxclass.Text;
                    i.Section      = comboboxsection.Text;
                    i.AdmitDate    = Admitdatepicker.Value.ToString();

                    if (bimage != null)
                    {
                        j.Profile = bimage;
                    }

                    db.Entry(i).State = System.Data.Entity.EntityState.Modified;
                    db.Entry(j).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBoxAdv.Show(ex.Message.ToString(), "Something Went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    db.Dispose();
                    MessageBox.Show("You have successfully updated a new record named as: " + txtstdname.Text, "New record added - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.None);
                    RESET = true;
                    this.Hide();
                }
            }
            else
            {
                MessageBox.Show("All fields are mandatory!", "Error - Student Management Sytem", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#6
0
 private void Bw_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         db.StudentDatas.Add(std);
         db.StudentProfiles.Add(stdprf);
         db.StudentFees.Add(stdfee);
         db.SaveChanges();
         error = false;
     }
     catch (Exception ex)
     {
         error = true;
         MessageBox.Show(ex.Message.ToString(), "Something Went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#7
0
        private void Bw_DoWork(object sender, DoWorkEventArgs e)
        {
            ArrayList ClassArray = new ArrayList();
            ArrayList FeeArray   = new ArrayList();


            var clas = db.Randoms.Where(c => c.ID == 26).FirstOrDefault();

            var clasarray = clas.Text.Split(',');

            ClassArray.AddRange(clasarray);


            for (int i = 1; i <= ClassArray.ToArray().Length; i++)
            {
                string             tfeeName = "tfee" + i.ToString();
                BunifuMetroTextbox tfee_txt = this.Controls.Find(tfeeName, true).FirstOrDefault() as BunifuMetroTextbox;


                string             efeeName = "efee" + i.ToString();
                BunifuMetroTextbox efee_txt = this.Controls.Find(efeeName, true).FirstOrDefault() as BunifuMetroTextbox;

                string fee = tfee_txt.Text + "," + efee_txt.Text;

                FeeArray.Add(fee);
            }

            string up = String.Join(";", FeeArray.ToArray());

            try
            {
                var fe = db.Randoms.Where(c => c.ID == 32).FirstOrDefault();
                fe.Text            = up.ToString();
                db.Entry(fe).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                done = true;
            }
            catch (Exception ex)
            {
                result = ex.Message.ToString();
                done   = false;
            }
            finally
            {
                result = "Saved Successfully!";
            }
        }
示例#8
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            var key = db.Randoms.Where(c => c.ID == 9).FirstOrDefault();

            key.Text = txtotherlabel.Text;

            var fee = db.Randoms.Where(c => c.ID == 10).FirstOrDefault();

            fee.Text = txtotherfee.Text;

            var vouch = db.Randoms.Where(c => c.ID == 12).FirstOrDefault();

            vouch.Text = txtvouch.Text;

            var late = db.Randoms.Where(c => c.ID == 11).FirstOrDefault();

            late.Text = txtlate.Text;

            var due = db.Randoms.Where(c => c.ID == 13).FirstOrDefault();

            due.Text = txtdue.Text;

            try
            {
                db.Entry(key).State   = System.Data.Entity.EntityState.Modified;
                db.Entry(fee).State   = System.Data.Entity.EntityState.Modified;
                db.Entry(vouch).State = System.Data.Entity.EntityState.Modified;
                db.Entry(late).State  = System.Data.Entity.EntityState.Modified;
                db.Entry(due).State   = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                labelresult.Text      = ex.Message.ToString();
                labelresult.Visible   = true;
                labelresult.ForeColor = Color.Red;
            }
            finally
            {
                labelresult.Text      = "Successfully Saved!";
                labelresult.Visible   = true;
                labelresult.ForeColor = Color.Green;
            }
        }
示例#9
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            if (txtstdname.Text != null && txtstdname.Text != "" && txtathername.Text != null && txtathername.Text != "" && txtregno.Text != null && txtregno.Text != "" &&
                txtmothername.Text != null && txtmothername.Text != "" && DateofBirthPicker.Text != null && DateofBirthPicker.Text != "" && txtaddress.Text != null && txtaddress.Text != "" &&
                txtplaceofbirth.Text != null && txtplaceofbirth.Text != "" && txtcnic.Text != null && txtcnic.Text != "" &&
                ComboBoxGender.Text != null && ComboBoxGender.Text != "" && txtreligion.Text != null && txtreligion.Text != "" &&
                txtcontact.Text != null && txtcontact.Text != "" && comboboxclass.Text != null && comboboxclass.Text != "" &&
                comboboxsection.Text != null && comboboxsection.Text != "" && Admitdatepicker.Text != null && Admitdatepicker.Text != "")
            {
                try
                {
                    var       data      = db.Randoms.Where(x => x.ID == 6).FirstOrDefault();
                    ArrayList arrayList = new ArrayList();
                    arrayList.AddRange(data.Text.Split(','));

                    bool classcheck = false;

                    for (int i = 0; i <= arrayList.ToArray().Length - 1; i++)
                    {
                        if (comboboxclass.Text == arrayList[i].ToString())
                        {
                            classcheck = true;
                        }
                    }


                    if (classcheck)
                    {
                        int index = 0;
                        for (int x = 0; x <= arrayList.ToArray().Length - 1; x++)
                        {
                            if (comboboxclass.Text == arrayList[x].ToString())
                            {
                                index = x;
                                break;
                            }
                        }
                        var othersfee = db.Randoms.Where(x => x.ID == 10).FirstOrDefault();
                        var latefee   = db.Randoms.Where(x => x.ID == 11).FirstOrDefault();
                        var fee       = db.Randoms.Where(x => x.ID == 8).FirstOrDefault();
                        var feearray  = fee.Text.Split(';');

                        var    feearray1 = feearray[index].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();


                        DateTime dob   = Convert.ToDateTime(DateofBirthPicker.Value);
                        DateTime admit = Convert.ToDateTime(Admitdatepicker.Value);

                        var i = db.StudentDatas.Where(c => c.ID == ModifyStudent.STUDENT_ID).FirstOrDefault();
                        var j = db.StudentProfiles.Where(d => d.ID == ModifyStudent.STUDENT_ID).FirstOrDefault();
                        var k = db.StudentFees.Where(c => c.ID == ModifyStudent.STUDENT_ID).FirstOrDefault();

                        i.StudentName  = txtstdname.Text;
                        i.FatherName   = txtathername.Text;
                        i.RegNo        = txtregno.Text;
                        i.MotherName   = txtmothername.Text;
                        i.DateOfBirth  = dob.ToString("dd/MM/yyyy");
                        i.PlaceOfBirth = txtplaceofbirth.Text;
                        i.Address      = txtaddress.Text;
                        i.NIC          = txtcnic.Text;
                        i.Gender       = ComboBoxGender.Text;
                        i.Religion     = txtreligion.Text;
                        i.Contact      = txtcontact.Text;
                        i.Class        = comboboxclass.Text;
                        i.Section      = comboboxsection.Text;
                        i.AdmitDate    = admit.ToString("dd/MM/yyyy");
                        i.Fees         = fees;

                        if (bimage != null)
                        {
                            j.Profile = bimage;
                        }

                        k.ExamFee = Convert.ToInt32(feearray1[1].ToString());

                        db.Entry(i).State = System.Data.Entity.EntityState.Modified;
                        db.Entry(j).State = System.Data.Entity.EntityState.Modified;
                        db.Entry(k).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    else
                    {
                    }
                }
                catch (Exception ex)
                {
                    MessageBoxAdv.Show(ex.Message.ToString(), "Something Went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    db.Dispose();
                    MessageBox.Show("You have successfully updated a new record named as: " + txtstdname.Text, "New record added - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.None);
                    RESET = true;
                    this.Hide();
                }
            }
            else
            {
                MessageBox.Show("All fields are mandatory!", "Error - Student Management Sytem", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#10
0
        private void SavingInformation()
        {
            try
            {
                Random ran1 = new Random()
                {
                    ID   = 1,
                    Key  = "School Name",
                    Text = txtschoolname.Text
                };

                Random ran2 = new Random()
                {
                    ID   = 2,
                    Key  = "Address",
                    Text = txtschooladdress.Text
                };

                Random ran3 = new Random()
                {
                    ID   = 3,
                    Key  = "Contact",
                    Text = txtschoolcontact.Text
                };

                Random ran4 = new Random()
                {
                    ID   = 4,
                    Key  = "Email",
                    Text = txtschoolEmail.Text
                };
                Random ran5 = new Random()
                {
                    ID   = 5,
                    Key  = "Owner Name",
                    Text = txtowner.Text
                };

                Random ran6 = new Random()
                {
                    ID   = 6,
                    Key  = "Classes",
                    Text = Classess().ToString()
                };

                Random ran7 = new Random()
                {
                    ID   = 7,
                    Key  = "Sections",
                    Text = Sections().ToString()
                };

                Random ran8 = new Random()
                {
                    ID   = 8,
                    Key  = "Classes Fee",
                    Text = ClassesFee().ToString()
                };

                Random ran9 = new Random()
                {
                    ID   = 9,
                    Key  = "Others Fee Label",
                    Text = txtothersfeelabel.Text
                };

                Random ran10 = new Random()
                {
                    ID   = 10,
                    Key  = "Others Fee",
                    Text = txtothersfee.Text
                };

                Random ran11 = new Random()
                {
                    ID   = 11,
                    Key  = "Late Fee",
                    Text = txtlatefee.Text
                };

                Random ran12 = new Random()
                {
                    ID   = 12,
                    Key  = "Voucher Charges",
                    Text = txtvouchcharges.Text
                };

                Random ran13 = new Random()
                {
                    ID   = 13,
                    Key  = "Due Date",
                    Text = txtduedate.Text
                };

                Random ran14 = new Random()
                {
                    ID   = 14,
                    Key  = "Total Fee Per Month",
                    Text = "0,0,0,0,0,0,0,0,0,0,0,0"
                };

                Random ran15 = new Random()
                {
                    ID   = 15,
                    Key  = "Every Submission",
                    Text = "0;0;0;0;0;0;0;0;0;0;0;0"
                };

                Random ran16 = new Random()
                {
                    ID   = 16,
                    Key  = "Submission Date",
                    Text = "0;0;0;0;0;0;0;0;0;0;0;0"
                };

                Random ran17 = new Random()
                {
                    ID   = 17,
                    Key  = "Submission Name",
                    Text = "0;0;0;0;0;0;0;0;0;0;0;0"
                };


                var guid = Guid.NewGuid();



                Random ran18 = new Random()
                {
                    ID   = 18,
                    Key  = "Unique ID",
                    Text = guid.ToString().Substring(0, 18).ToString()
                };


                UserLogin user = new UserLogin()
                {
                    UserName = txtuser.Text,
                    Password = txtpass.Text
                };


                db.Randoms.Add(ran1);
                db.Randoms.Add(ran2);
                db.Randoms.Add(ran3);
                db.Randoms.Add(ran4);
                db.Randoms.Add(ran5);
                db.Randoms.Add(ran6);
                db.Randoms.Add(ran7);
                db.Randoms.Add(ran8);
                db.Randoms.Add(ran9);
                db.Randoms.Add(ran10);
                db.Randoms.Add(ran11);
                db.Randoms.Add(ran12);
                db.Randoms.Add(ran13);
                db.Randoms.Add(ran14);
                db.Randoms.Add(ran15);
                db.Randoms.Add(ran16);
                db.Randoms.Add(ran17);
                db.Randoms.Add(ran18);

                db.UserLogins.Add(user);

                db.SaveChanges();

                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:" + txtowner.Text);
                    sw.WriteLine("School Name:" + txtschoolname.Text);
                    sw.WriteLine("School Address:" + txtschooladdress.Text);
                    sw.WriteLine("School Contact:" + txtschoolcontact.Text);
                    sw.WriteLine("School Email:" + txtschoolEmail.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") + "," + guid.ToString().Substring(0, 18).ToString() + "," + txtowner.Text + "," + txtschoolname.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() + " " + ex.InnerException.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#11
0
        private void btnsubmit_Click(object sender, EventArgs e)
        {
            int remain = 0;

            int  enteredamount;
            bool interger = int.TryParse(txtpaying.Text, out enteredamount);


            if (ID != 0)
            {
                if (interger)
                {
                    if (total != 0 || totaldue != 0)
                    {
                        if (enteredamount != 0 && (enteredamount <= total || enteredamount <= totaldue) && enteredamount > 0)
                        {
                            if (DateTime.Now.Day > 10)
                            {
                                remain = totaldue - enteredamount;
                            }
                            else
                            {
                                remain = total - enteredamount;
                            }

                            try
                            {
                                var stddata = db.StudentDatas.Where(c => c.ID == ID).FirstOrDefault();
                                var stdfee  = db.StudentFees.Where(c => c.ID == ID).FirstOrDefault();

                                stddata.Arrears      = remain;
                                stdfee.Arrears       = remain;
                                stdfee.Submitted     = true;
                                stdfee.SubmittedDate = DateTime.Now.ToString("dd/MM/yyyy");



                                if (MessageBox.Show("Are you sure you want to submit fee of " + StudentName + "?", "Fee Submission - Student Management System", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                                {
                                    db.Entry(stddata).State = System.Data.Entity.EntityState.Modified;
                                    db.Entry(stdfee).State  = System.Data.Entity.EntityState.Modified;
                                    db.SaveChanges();

                                    FeePerMonth(enteredamount);
                                    FeeSubmit(enteredamount, DateTime.Now.ToString("dd/MM/yyyy hh:mm tt"), StudentName);

                                    MessageBox.Show("Fee Submitted Succcessfully at " + DateTime.Now.ToString("dd/MM/yyyy hh:mm tt"), "Fee Submitted - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                    btnreset_Click(sender, e);
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message.ToString(), "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            labelresult.Text      = "*Enter enter a right amount!";
                            labelresult.Visible   = true;
                            labelresult.ForeColor = Color.Red;
                        }
                    }
                }
                else
                {
                    labelresult.Text      = "*Enter enter a right amount!";
                    labelresult.Visible   = true;
                    labelresult.ForeColor = Color.Red;
                }
            }
            else
            {
                labelresult.Text      = "*Please search Student first!";
                labelresult.Visible   = true;
                labelresult.ForeColor = Color.Red;
            }
        }
示例#12
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);
            }
        }