Example #1
0
        private void errorReportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string[] filePaths = Directory.GetFiles("Logs");
            FileInfo filename;

            try
            {
                var desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                var fullFileName = Path.Combine(desktopFolder, "Logs");

                if (!Directory.Exists(fullFileName))
                {
                    Directory.CreateDirectory(fullFileName);
                }

                for (int i = 1; i < filePaths.Length; i++)
                {
                    filename = new FileInfo(filePaths[i]);

                    File.Copy(filePaths[i], Path.Combine(fullFileName, filename.Name));
                }

                MessageBox.Show("File Export completed");
            }
            catch (Exception err)
            {
                MessageBox.Show("File or Directory Already Exists", "File Copy Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CreateLogFile Err = new CreateLogFile();
                Err.ErrorLog("ErrorLog", "Export method of FormSelection:" + err.Message);
            }
        }
Example #2
0
        private void bAdd_Click(object sender, EventArgs e)
        {
            if (cid.Text == "" || cfname.Text == "" || clname.Text == "" || cemail.Text == "" || cnum.Text == "" || cpos.Text == "" || ccity.Text == "" || ccntry.Text == "" || cnpos.Text =="" || caddr.Text == "")
            {
                MessageBox.Show("Please fill in the required fields marked in red.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    con.Open();

                    cmdnewdb = new MySqlCommand("insert into company(cpyname,spocfname,spoclname,position,number,email,fax,city,country,zipcode,address,jobsavail,jobresp,jobreq,jobdesc,cmpid) values(@name,@sf,@sl,@pos,@num,@mail,@fx,@cty,@ctry,@zcode,@addr,@tot,@resp,@req,@desc,@id)", con);

                    cmdnewdb.Parameters.AddWithValue("id", int.Parse(cid.Text));
                    cmdnewdb.Parameters.AddWithValue("name", cname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("sf", cfname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("sl", clname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("pos", cpos.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("num", cnum.Text);
                    cmdnewdb.Parameters.AddWithValue("mail", cemail.Text);
                    cmdnewdb.Parameters.AddWithValue("fx", cfax.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("cty", ccity.Text);
                    cmdnewdb.Parameters.AddWithValue("ctry", ccntry.Text);
                    cmdnewdb.Parameters.AddWithValue("zcode", cpostal.Text == "" ? 0 : int.Parse(cpostal.Text));
                    cmdnewdb.Parameters.AddWithValue("addr", caddr.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("tot", int.Parse(cnpos.Text));
                    cmdnewdb.Parameters.AddWithValue("resp", cresp.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("req", creq.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("desc", cdesc.Text.Trim());

                    cmdnewdb.ExecuteNonQuery();
                    MessageBox.Show("Company Details Added Succesfully", "Add Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmdnewdb.Parameters.Clear();

                    clearControls(sender, e);

                }
                catch (Exception err)
                {
                    MessageBox.Show("Problem can be due to following reasons: \n\n1.Company ID already Exists\n2. Problem with Database Connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CreateLogFile Err = new CreateLogFile();
                    Err.ErrorLog("ErrorLog", "Add method of CompanyForm Page :" + err.Message);
                }//End of Catch
                finally
                {
                    con.Close();
                }

            }//End of Outer If-Else
        }
Example #3
0
        private void bDelete_Click(object sender, EventArgs e)
        {
            int status;

            if (facid.Text == "")
            {
                MessageBox.Show("Please enter an Faculty ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                facid.Focus();
            }
            else
            {
                try
                {
                    con.Open();
                    cmdnewdb = new MySqlCommand("delete from faculty where facid=@fid", con);
                    cmdnewdb.Parameters.AddWithValue("fid", int.Parse(facid.Text.Trim()));
                    status = cmdnewdb.ExecuteNonQuery();

                    if(status > 0)
                    {
                        MessageBox.Show("Faculty Details Deleted Succesfully", "Update Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        cmdnewdb.Parameters.Clear();
                    }
                    else
                    {
                        MessageBox.Show("No Records Found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        facid.SelectAll();
                        facid.Focus();
                        dr.Close();
                    }
                    con.Close();
                    clearControls(sender, e);
                }
                catch (Exception err)
                {
                    MessageBox.Show("Problem may be: Database Connection doe not exist. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CreateLogFile Err = new CreateLogFile();
                    Err.ErrorLog("ErrorLog", "Delete method of Faculty Page :" + err.Message);
                }
            }
        }
        private void bAdd_Click(object sender, EventArgs e)
        {
            if (studstat.Text == "" || tfname.Text == "" || tmname.Text == "" || size.Text == "" || pdesc.Text == "" || tcname.Text == "" || istatus.Text == "" || title.Text == "")
            {
                MessageBox.Show("Please fill in all the fields.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
               try
                {
                    con.Open();

                    cmdnewdb = new MySqlCommand("insert into internship(studid,status,cname,mgrname,facname,title,size,istatus,pdesc) values(@sid,@st,@name,@mgr,@fac,@head,@tot,@istat,@desc)", con);

                    cmdnewdb.Parameters.AddWithValue("sid", sid);
                    cmdnewdb.Parameters.AddWithValue("st", studstat.SelectedItem.ToString());
                    cmdnewdb.Parameters.AddWithValue("name", tcname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("mgr", tmname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("fac", tfname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("head", title.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("tot",int.Parse(size.Text));
                    cmdnewdb.Parameters.AddWithValue("istat", istatus.SelectedItem.ToString());
                    cmdnewdb.Parameters.AddWithValue("desc", pdesc.Text.Trim());

                    cmdnewdb.ExecuteNonQuery();
                    MessageBox.Show("Student Internship Details Added Succesfully", "Add Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmdnewdb.Parameters.Clear();

                    con.Close();
                    this.Hide();
                }
                catch (Exception err)
                {
                    MessageBox.Show("There is a problem with input values. Please provide valid inputs.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CreateLogFile Err = new CreateLogFile();
                    Err.ErrorLog("ErrorLog", "Add Student method of StudentInternship Page :" + err.Message);
                }//End of Catch
            }//End of Outer If-Else
        }
        private void bDelete_Click(object sender, EventArgs e)
        {
            int status;

               if(sid.Text!="")
               {
            try
            {
                con.Open();
                cmdnewdb = new MySqlCommand("delete from education where studid=@id", con);
                cmdnewdb.Parameters.AddWithValue("id", sid.Text.Trim());
                status = cmdnewdb.ExecuteNonQuery();

                if (status > 0)
                {
                    MessageBox.Show("Student Education Details Deleted Succesfully", "Delete Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No records found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                cmdnewdb.Parameters.Clear();
                con.Close();

            }
            catch (Exception err)
            {
                MessageBox.Show("Problem may be: Database Connection doe not exist or Invalid Student ID. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CreateLogFile Err = new CreateLogFile();
                Err.ErrorLog("ErrorLog", "Delete method of Student Education Page :" + err.Message);
            }
               }
               else
               {
            MessageBox.Show("Please enter a student ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
               sid.SelectAll();
               sid.Focus();
               }
        }
Example #6
0
        private void bSave_Click(object sender, EventArgs e)
        {
            if (facid.Text == "" || fname.Text == "" || lname.Text == "" || desig.Text == "" || mobile.Text == "" || email.Text == "" || dept.SelectedIndex == -1 || number.Text == "")
            {
                MessageBox.Show("Please fill in all the required fields marked in red.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (mobile.Text.Length < 10)
            {
                MessageBox.Show("Please enter 10-digit mobile number.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                 try
                 {
                con.Open();

                cmdnewdb = new MySqlCommand("select * from faculty where facid =@fid",con);
                cmdnewdb.Parameters.AddWithValue("fid", int.Parse(facid.Text.Trim()));
                dr = cmdnewdb.ExecuteReader();
                dr.Read();
                if (dr.HasRows)  // if the id is already in database then return true
                {
                    MessageBox.Show("Duplicate Faculty ID. Please give another ID.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    facid.SelectAll();
                    facid.Focus();
                    dr.Close();
                }
                else
                {
                    dr.Close();
                    cmdnewdb = new MySqlCommand("insert into faculty(fname,lname,number,desig,dept,extn,mobile,email,notes,facid) values(@name1,@name2,@num,@des,@dpt,@ext,@mob,@mail,@note,@id)", con);
                    cmdnewdb.Parameters.AddWithValue("id", int.Parse(facid.Text.Trim()));
                    cmdnewdb.Parameters.AddWithValue("name1", fname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("name2", lname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("des", desig.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("dpt", dept.SelectedItem.ToString());
                    cmdnewdb.Parameters.AddWithValue("num", number.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("ext", extn.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("mob", mobile.Text);
                    cmdnewdb.Parameters.AddWithValue("mail", email.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("note", notes.Text.Trim());

                    cmdnewdb.ExecuteNonQuery();
                    MessageBox.Show("Faculty Details Added Succesfully", "Add Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmdnewdb.Parameters.Clear();

                    clearControls(sender, e);
                }
                con.Close();
            }
                 catch (Exception err)
                 {
                     MessageBox.Show("There must be a Database Connection Problem. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     CreateLogFile Err = new CreateLogFile();
                     Err.ErrorLog("ErrorLog", "Save method of Faculty Page :" + err.Message);
                 }//End of Catch
            }//End of Outer If-Else
        }
Example #7
0
        private void bUpdate_Click(object sender, EventArgs e)
        {
            if (facid.Text == "")
            {
                MessageBox.Show("Please enter an Faculty ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                facid.Focus();
            }
            else
            {
                try
                {
                    con.Open();
                    cmdnewdb = new MySqlCommand("select * from faculty where facid=@fid", con);
                    cmdnewdb.Parameters.AddWithValue("fid", int.Parse(facid.Text.Trim()));
                    dr = cmdnewdb.ExecuteReader();
                    dr.Read();
                    if (dr.HasRows)
                    {
                        dr.Close();
                        cmdnewdb = new MySqlCommand("update faculty set fname=@name1,lname=@name2,number=@num,desig=@des,dept=@dpt,extn=@ext,mobile=@mob,email=@mail,notes=@note where facid=@id", con);
                        cmdnewdb.Parameters.AddWithValue("id", int.Parse(facid.Text.Trim()));
                        cmdnewdb.Parameters.AddWithValue("name1", fname.Text.Trim());
                        cmdnewdb.Parameters.AddWithValue("name2", lname.Text.Trim());
                        cmdnewdb.Parameters.AddWithValue("des", desig.Text.Trim());
                        cmdnewdb.Parameters.AddWithValue("dpt", dept.SelectedItem.ToString());
                        cmdnewdb.Parameters.AddWithValue("num", number.Text.Trim());
                        cmdnewdb.Parameters.AddWithValue("ext", extn.Text.Trim());
                        cmdnewdb.Parameters.AddWithValue("mob", mobile.Text);
                        cmdnewdb.Parameters.AddWithValue("mail", email.Text.Trim());
                        cmdnewdb.Parameters.AddWithValue("note", notes.Text.Trim());

                        cmdnewdb.ExecuteNonQuery();
                        MessageBox.Show("Faculty Details Updated Succesfully", "Update Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        cmdnewdb.Parameters.Clear();
                    }
                    else
                    {
                        MessageBox.Show("No Records Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        facid.SelectAll();
                        facid.Focus();
                        dr.Close();
                    }
                    con.Close();
                }
                catch (Exception err)
                {
                    MessageBox.Show("Problem may be due to incorrect ID. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CreateLogFile Err = new CreateLogFile();
                    Err.ErrorLog("ErrorLog", "Update method of Faculty Page :" + err.Message);
                }
            }
        }
Example #8
0
        private void bSearch_Click(object sender, EventArgs e)
        {
            if (facid.Text == "")
            {
                MessageBox.Show("Please enter an Faculty ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                facid.Focus();
            }
            else
            {
                try
                {
                    con.Open();
                    cmdnewdb = new MySqlCommand("select * from faculty where facid=@fid", con);
                    cmdnewdb.Parameters.AddWithValue("fid", int.Parse(facid.Text.Trim()));
                    dr = cmdnewdb.ExecuteReader();
                    dr.Read();
                    if (dr.HasRows)
                    {
                        fname.Text = dr.GetString("fname");
                        lname.Text = dr.GetString("lname");
                        number.Text = dr.GetString("number");
                        desig.Text = dr.GetString("desig");
                        extn.Text = dr.GetString("extn");
                        mobile.Text = dr.GetString("mobile");
                        email.Text = dr.GetString("email");
                        notes.Text = dr.GetString("notes");
                        dept.Text = dr.GetString("dept");

                        dr.Close();
                    }
                    else
                    {
                        MessageBox.Show("No Records Found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        facid.SelectAll();
                        facid.Focus();
                        dr.Close();
                    }
                    con.Close();
                }
                catch (Exception err)
                {
                    MessageBox.Show("Problem may be due to incorrect ID. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CreateLogFile Err = new CreateLogFile();
                    Err.ErrorLog("ErrorLog", "Search method of Faculty Page :" + err.Message);
                }
            }
        }
Example #9
0
        private void bAdd_Click(object sender, EventArgs e)
        {
            String flist ="", llist= "";

            if (locList.Items.Count == 0 || fieldList.Items.Count == 0)
            {
                MessageBox.Show("Please fill in all the fields.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (locname.SelectedIndex == locname.Items.Count - 1 && others.Text == "")
            {
                MessageBox.Show("Please enter Other Location.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    //Adding all items of fieldlist to one string variable
                    for (int fcnt = 0; fcnt < fieldList.Items.Count; fcnt++)
                    {
                        flist += fieldList.Items[fcnt].ToString() + ",";
                    }

                    //Adding all items of loclist to one string variable
                    for (int lcnt = 0; lcnt < locList.Items.Count; lcnt++)
                    {
                        llist += locList.Items[lcnt].ToString() + ",";
                    }

                    con.Open();

                    cmdnewdb = new MySqlCommand("insert into interest(studid,fieldlist,loclist,comments) values(@sid,@field,@loc,@comm)", con);

                    cmdnewdb.Parameters.AddWithValue("sid", sid);
                    cmdnewdb.Parameters.AddWithValue("field", flist);
                    cmdnewdb.Parameters.AddWithValue("loc", locList.Items);
                    cmdnewdb.Parameters.AddWithValue("comm", comments.Text.Trim());

                    cmdnewdb.ExecuteNonQuery();
                    MessageBox.Show("Student Interest Details Added Succesfully", "Add Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmdnewdb.Parameters.Clear();

                    con.Close();

                    clearControls(sender, e);

                }
                catch (Exception err)
                {
                    MessageBox.Show("Student Id does not exist. Please provide valid ID.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CreateLogFile Err = new CreateLogFile();
                    Err.ErrorLog("ErrorLog", "Add method of StudentInterest Page :" + err.Message);
                }//End of Catch
            }//End of Outer If-Else
        }
Example #10
0
        private void bDelete_Click(object sender, EventArgs e)
        {
            int status;
            try
            {
                con.Open();
                cmdnewdb = new MySqlCommand("delete from skills where studid=@id", con);
                cmdnewdb.Parameters.AddWithValue("id", sid);
                status = cmdnewdb.ExecuteNonQuery();

                if (status > 0)
                {
                    MessageBox.Show("Knowledge and Skills Details Deleted Succesfully", "Delete Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No records found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                cmdnewdb.Parameters.Clear();
                con.Close();
                clearControls(sender, e);
            }
            catch (Exception err)
            {
                MessageBox.Show("Problem may be: Database Connection doe not exist. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CreateLogFile Err = new CreateLogFile();
                Err.ErrorLog("ErrorLog", "Delete method of Student Skills Page :" + err.Message);
            }
        }
Example #11
0
        private void bUpdate_Click(object sender, EventArgs e)
        {
            if (cid.Text == "" || cfname.Text == "" || clname.Text == "" || cemail.Text == "" || cnum.Text == "" || cpos.Text == "" || ccity.Text == "" || ccntry.Text == "" || cnpos.Text == "" || caddr.Text == "")
            {
                MessageBox.Show("Please fill in the required fields marked in red.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    con.Open();

                    cmdnewdb = new MySqlCommand("update company set cpyname=@name,spocfname=@sf,spoclname=@sl,position=@pos,number=@num,email=@mail,fax=@fx,city=@cty,country=@ctry,zipcode=@zcode,address=@addr,jobsavail=@tot,jobresp=@resp,jobreq=@req,jobdesc=@desc where cmpid=@cid", con);

                    cmdnewdb.Parameters.AddWithValue("id", cid.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("name", cname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("sf", cfname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("sl", clname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("pos", cpos.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("num", cnum.Text);
                    cmdnewdb.Parameters.AddWithValue("mail", cemail.Text);
                    cmdnewdb.Parameters.AddWithValue("fx", cfax.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("cty", ccity.Text);
                    cmdnewdb.Parameters.AddWithValue("ctry", ccntry.Text);
                cmdnewdb.Parameters.AddWithValue("zcode",cpostal.Text==""?0:int.Parse(cpostal.Text));
                    cmdnewdb.Parameters.AddWithValue("addr", caddr.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("tot", int.Parse(cnpos.Text));
                    cmdnewdb.Parameters.AddWithValue("resp", cresp.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("req", creq.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("desc", cdesc.Text.Trim());

                    cmdnewdb.ExecuteNonQuery();
                    MessageBox.Show("Company Details Updated Succesfully", "Update Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmdnewdb.Parameters.Clear();

                    con.Close();

                    clearControls(sender, e);

                }
                catch (Exception err)
                {
                    MessageBox.Show("There is a problem with input values. Please provide valid inputs.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CreateLogFile Err = new CreateLogFile();
                    Err.ErrorLog("ErrorLog", "Update method of CompanyForm Page :" + err.Message);
                }//End of Catch
                finally
                {
                    con.Close();
                }
            }//End of Outer If-Else
        }
Example #12
0
        private void bSearch_Click(object sender, EventArgs e)
        {
            if (cid.Text != "")
            {
              try
            {
                con.Open();
                cmdnewdb = new MySqlCommand("select * from company where cmpid=@fid", con);
                cmdnewdb.Parameters.AddWithValue("fid", cid.Text.Trim());
                dr = cmdnewdb.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    cname.Text = dr.GetString("cpyname");
                    cfname.Text = dr.GetString("spocfname");
                    clname.Text = dr.GetString("spoclname");
                    cnum.Text = dr.GetString("number");
                    cpos.Text = dr.GetString("position");
                    cemail.Text = dr.GetString("email");
                    cpostal.Text = dr.GetString("zipcode");
                    ccity.Text = dr.GetString("city");
                    ccntry.Text = dr.GetString("country");
                    cfax.Text = dr.GetString("fax");
                    caddr.Text = dr.GetString("address");
                    cnpos.Text = dr.GetString("jobsavail");
                    cresp.Text = dr.GetString("jobresp");
                    creq.Text = dr.GetString("jobreq");
                    cdesc.Text = dr.GetString("jobdesc");
                }
                else
                {
                    MessageBox.Show("No records found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    dr.Close();
                }

            }
             catch (Exception err)
              {
                 MessageBox.Show("Problem may be due to incorrect ID. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 CreateLogFile Err = new CreateLogFile();
                 Err.ErrorLog("ErrorLog", "Search method of Student Skills Page :" + err.Message);
              }
              finally
              {
                  con.Close();
              }
            }
            else
            {
                MessageBox.Show("Please enter valid company ID.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cid.SelectAll();
                cid.Focus();
            }
        }
Example #13
0
        private void getData(String name)
        {
            DataSet ds = new DataSet();

            try
            {
                con.Open();
                cmd = new MySqlCommand("select * from " + name, con);
                da = new MySqlDataAdapter(cmd);
                da.Fill(ds, name);
                dt = ds.Tables[name];
                if (dt.Rows.Count < 1)
                {
                    dataGridView1.DataSource = null;
                    dataGridView1.Refresh();
                    MessageBox.Show("No Records Found", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    BindingSource bSource = new BindingSource();
                    bSource.DataSource = dt;
                    dataGridView1.Refresh();
                    dataGridView1.DataSource = bSource;
                }
                con.Close();
            }
            catch (Exception err)
            {
                MessageBox.Show("There must be a Database Connection Problem. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CreateLogFile Err = new CreateLogFile();
                Err.ErrorLog("ErrorLog", "GetData method of Report Page :" + err.Message);
            }
        }
Example #14
0
        private void bSearch_Click(object sender, EventArgs e)
        {
            String[] dlst,mlst,glst,clst,plst,ylst,cname,fdt,tdt,desg,dut;

              try
            {
                con.Open();
                cmdnewdb = new MySqlCommand("select * from education where studid=@fid", con);
                cmdnewdb.Parameters.AddWithValue("fid", sid.Text.Trim());
                dr = cmdnewdb.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    if (dr.GetString("semreg") == "Fall")
                        optfall.Checked = true;
                    else
                        optwinter.Checked = true;

                    regyr.Text = dr.GetString("semyr");
                    sfname.Text = dr.GetString("fname");
                    slname.Text = dr.GetString("lname");
                    smname.Text = dr.GetString("mname");
                    semail.Text = dr.GetString("email");
                    snum.Text = dr.GetString("number");

                    if (dr.GetString("status") == "International")
                        status1.Checked = true;
                    else
                        status2.Checked = true;

                    dlst = dr.GetString("degree").Split('/');

                    cDegree1.Text = dr.GetString(dlst[0]);
                    cDegree2.Text = dr.GetString(dlst[1]);
                    cDegree3.Text = dr.GetString(dlst[2]);
                    cDegree4.Text = dr.GetString(dlst[3]);

                    mlst = dr.GetString("major").Split('/');

                    Major1.Text = dr.GetString(mlst[0]);
                    Major2.Text = dr.GetString(mlst[1]);
                    Major3.Text = dr.GetString(mlst[2]);
                    Major4.Text = dr.GetString(mlst[3]);

                    glst = dr.GetString("gpa").Split('/');

                    GPA1.Text = dr.GetString(glst[0]);
                    GPA2.Text = dr.GetString(glst[1]);
                    GPA3.Text = dr.GetString(glst[2]);
                    GPA4.Text = dr.GetString(glst[3]);

                    clst = dr.GetString("college").Split('/');

                    College1.Text = dr.GetString(clst[0]);
                    College2.Text = dr.GetString(clst[1]);
                    College3.Text = dr.GetString(clst[2]);
                    College4.Text = dr.GetString(clst[3]);

                    plst = dr.GetString("place").Split('/');

                    Place1.Text = dr.GetString(plst[0]);
                    Place2.Text = dr.GetString(plst[1]);
                    Place3.Text = dr.GetString(plst[2]);
                    Place4.Text = dr.GetString(plst[3]);

                    ylst = dr.GetString("year").Split('/');

                    year1.Text = dr.GetString(ylst[0]);
                    year2.Text = dr.GetString(ylst[1]);
                    year3.Text = dr.GetString(ylst[2]);
                    year4.Text = dr.GetString(ylst[3]);

                    cname = dr.GetString("compname").Split('/');

                    tComp1.Text = dr.GetString(cname[0]);
                    tComp2.Text = dr.GetString(cname[1]);
                    tComp3.Text = dr.GetString(cname[2]);

                    fdt = dr.GetString("fromdate").Split('/');

                    cFrmDt1.Text = dr.GetString(fdt[0].Substring(0,fdt[0].IndexOf('-')));
                    cFrmDt2.Text = dr.GetString(fdt[1].Substring(0, fdt[1].IndexOf('-')));
                    cFrmDt3.Text = dr.GetString(fdt[2].Substring(0, fdt[2].IndexOf('-')));
                    cFrmYr1.Text = dr.GetString(fdt[0].Substring(fdt[0].IndexOf('-'))+1);
                    cFrmYr2.Text = dr.GetString(fdt[1].Substring(fdt[1].IndexOf('-'))+1);
                    cFrmYr3.Text = dr.GetString(fdt[2].Substring(fdt[2].IndexOf('-'))+1);

                    tdt = dr.GetString("todate").Split('/');

                    cToDt1.Text = dr.GetString(tdt[0].Substring(0, tdt[0].IndexOf('-')));
                    cToDt2.Text = dr.GetString(tdt[1].Substring(0, tdt[1].IndexOf('-')));
                    cToDt3.Text = dr.GetString(tdt[2].Substring(0, tdt[2].IndexOf('-')));
                    cToYr1.Text = dr.GetString(tdt[0].Substring(tdt[0].IndexOf('-')) + 1);
                    cToYr2.Text = dr.GetString(tdt[1].Substring(tdt[1].IndexOf('-')) + 1);
                    cToYr3.Text = dr.GetString(tdt[2].Substring(tdt[2].IndexOf('-')) + 1);

                    desg = dr.GetString("desig").Split('/');

                    tDesig1.Text = dr.GetString(desg[0]);
                    tDesig2.Text = dr.GetString(desg[1]);
                    tDesig3.Text = dr.GetString(desg[2]);

                    dut = dr.GetString("duties").Split('/');

                    tDuty1.Text = dr.GetString(dut[0]);
                    tDuty2.Text = dr.GetString(dut[1]);
                    tDuty3.Text = dr.GetString(dut[2]);
                }
                else
                {
                    MessageBox.Show("No records found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    dr.Close();
                }
                con.Close();
            }
              catch (Exception err)
              {
                  MessageBox.Show("Problem may be due to incorrect ID. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                  CreateLogFile Err = new CreateLogFile();
                  Err.ErrorLog("ErrorLog", "Search method of Student Skills Page :" + err.Message);
              }
        }
Example #15
0
        private void bSearch_Click(object sender, EventArgs e)
        {
            string[] plst, llst,flst,olst,clst;

            try
            {
                con.Open();
                cmdnewdb = new MySqlCommand("select * from skills where studid=@fid", con);
                cmdnewdb.Parameters.AddWithValue("fid", sid);
                dr = cmdnewdb.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    plst = dr.GetString("proglist").Split(',');
                    clst = dr.GetString("cmslist").Split(',');
                    olst = dr.GetString("oslist").Split(',');
                    flst = dr.GetString("fieldlist").Split(',');
                    llst = dr.GetString("langlist").Split(',');

                    foreach (String s in plst)
                    {
                        plangList.Items.Add(s);
                    }
                    foreach (String s in clst)
                    {
                        cmsList.Items.Add(s);
                    }
                    foreach (String s in olst)
                    {
                        osList.Items.Add(s);
                    }
                    foreach (String s in flst)
                    {
                        fieldList.Items.Add(s);
                    }
                    foreach (String s in llst)
                    {
                        langList.Items.Add(s);
                    }

                    dr.Close();
                }
                else
                {
                    MessageBox.Show("No records found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    dr.Close();
                }
                con.Close();
            }
            catch (Exception err)
            {
                MessageBox.Show("Problem may be due to incorrect ID. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CreateLogFile Err = new CreateLogFile();
                Err.ErrorLog("ErrorLog", "Search method of Student Skills Page :" + err.Message);
            }
        }
Example #16
0
        private void bAdd_Click(object sender, EventArgs e)
        {
            String degree = "", fromDate = "", todate = "";

            if (sid.Text == ""  || sfname.Text =="" || slname.Text=="" || semail.Text=="" || snum.Text == "")
            {
                MessageBox.Show("Please fill in the required fields.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    con.Open();

                    cmdnewdb = new MySqlCommand("insert into education(semreg,studid,fname,lname,mname,email,number,status,degree,major,gpa,college,place,year,compname,fromdate,todate,desig,duties,semyr) values(@reg,@id,@name1,@name2,@name3,@mail,@num,@stat,@deg,@maj,@mark,@coll,@loc,@yr,@cname,@fdate,@tdate,@desg,@duty,@semyr)", con);

                    if (optfall.Checked == true)
                    {
                        cmdnewdb.Parameters.AddWithValue("reg", optfall.Text);
                    }
                    else if (optwinter.Checked == true)
                    {
                        cmdnewdb.Parameters.AddWithValue("reg", optwinter.Text);
                    }

                    cmdnewdb.Parameters.AddWithValue("id", int.Parse(sid.Text));
                    cmdnewdb.Parameters.AddWithValue("name1", sfname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("name2", slname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("name3", smname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("mail", semail.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("num", int.Parse(snum.Text));

                    if (status1.Checked == true)
                    {
                        cmdnewdb.Parameters.AddWithValue("stat", status1.Text);
                    }
                    else if (status2.Checked == true)
                    {
                        cmdnewdb.Parameters.AddWithValue("stat", status2.Text);
                    }
                    else
                    {
                        cmdnewdb.Parameters.AddWithValue("stat","");
                    }

                    degree = cDegree1.SelectedValue + "/" + cDegree2.SelectedValue + "/" + cDegree3.SelectedValue + "/" + cDegree4.SelectedValue;
                    cmdnewdb.Parameters.AddWithValue("deg", degree);

                    cmdnewdb.Parameters.AddWithValue("maj", Major1.Text + "/" + Major2.Text + "/" + Major3.Text + "/" + Major4.Text);
                    cmdnewdb.Parameters.AddWithValue("mark", GPA1.Text + "/" + GPA2.Text + "/" + GPA3.Text + "/" + GPA4.Text);
                    cmdnewdb.Parameters.AddWithValue("coll", College1.Text + "/" + College2.Text + "/" + College3.Text + "/" + College4.Text);
                    cmdnewdb.Parameters.AddWithValue("loc", Place1.Text + "/" + Place2.Text + "/" + Place3.Text + "/" + Place4.Text);
                    cmdnewdb.Parameters.AddWithValue("yr", year1.Text + "/" + year2.Text + "/" + year3.Text + "/" + year4.Text);
                    cmdnewdb.Parameters.AddWithValue("cname", tComp1.Text + "/" + tComp2.Text + "/" + tComp3.Text);

                    fromDate = cFrmDt1.SelectedValue + "-" + cFrmYr1.SelectedText + "/"
                             + cFrmDt2.SelectedValue + "-" + cFrmYr2.SelectedText + "/"
                             + cFrmDt3.SelectedValue + "-" + cFrmYr3.SelectedText;
                    cmdnewdb.Parameters.AddWithValue("fdate",fromDate);

                    todate = cToDt1.SelectedValue + "-" + cToYr1.SelectedText + "/"
                             + cToDt2.SelectedValue + "-" + cToYr2.SelectedText + "/"
                             + cToDt3.SelectedValue + "-" + cToYr3.SelectedText;
                    cmdnewdb.Parameters.AddWithValue("tdate", todate);
                    cmdnewdb.Parameters.AddWithValue("desg", tDesig1.Text + "/" + tDesig2.Text + "/" + tDesig3.Text);
                    cmdnewdb.Parameters.AddWithValue("duty", tDuty1.Text + "/" + tDuty2.Text + "/" + tDuty3.Text);
                    cmdnewdb.Parameters.AddWithValue("semyr",int.Parse(regyr.Text));

                    cmdnewdb.ExecuteNonQuery();
                    MessageBox.Show("Student Details Added Succesfully", "Add Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmdnewdb.Parameters.Clear();

                    con.Close();

                }
                catch (Exception err)
                {
                    MessageBox.Show("There is a problem with input values. Please provide valid inputs.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CreateLogFile Err = new CreateLogFile();
                    Err.ErrorLog("ErrorLog", "Add Student method of StudentEducation Page :" + err.Message);
                }//End of Catch
            }//End of Outer If-Else
        }
Example #17
0
        private void bUpdate_Click(object sender, EventArgs e)
        {
            String flist = "", llist = "", plist = "", olist = "", clist = "";

            if (lang.Items.Count == 0 || langList.Items.Count == 0 || fieldList.Items.Count == 0 || cmsList.Items.Count == 0 || osList.Items.Count == 0)
            {
                MessageBox.Show("Please fill in all the fields.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (lang.SelectedIndex == lang.Items.Count - 1 && pothers.Text == "")
            {
                MessageBox.Show("Please Other Programming Language.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (ccms.SelectedIndex == ccms.Items.Count - 1 && cmsother.Text == "")
            {
                MessageBox.Show("Please Other CMS Name.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (cos.SelectedIndex == cos.Items.Count - 1 && osother.Text == "")
            {
                MessageBox.Show("Please Other OS Name.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (clang.SelectedIndex == clang.Items.Count - 1 && langother.Text == "")
            {
                MessageBox.Show("Please Other Language.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    //Concatenating all items of programming language list
                    for (int pcnt = 0; pcnt < plangList.Items.Count; pcnt++)
                    {
                        if (plist == "")
                            plist += plangList.Items[pcnt].ToString();
                        else
                            plist += "," + plangList.Items[pcnt].ToString();
                    }

                    //Concatenating all items of cms list
                    for (int ccnt = 0; ccnt < cmsList.Items.Count; ccnt++)
                    {
                        if (clist == "")
                            clist += cmsList.Items[ccnt].ToString();
                        else
                            clist += "," + cmsList.Items[ccnt].ToString();
                    }

                    //Concatenating all items of os list
                    for (int ocnt = 0; ocnt < osList.Items.Count; ocnt++)
                    {
                        if (olist == "")
                            olist += osList.Items[ocnt].ToString();
                        else
                            olist += "," + osList.Items[ocnt].ToString();
                    }

                    //Concatenating all items of field list
                    for (int fcnt = 0; fcnt < fieldList.Items.Count; fcnt++)
                    {
                        if (flist == "")
                            flist += fieldList.Items[fcnt].ToString();
                        else
                            flist += "," + fieldList.Items[fcnt].ToString();
                    }

                    //Concatenating all items of lang list
                    for (int gcnt = 0; gcnt < langList.Items.Count; gcnt++)
                    {
                        if (llist == "")
                            llist += langList.Items[gcnt].ToString();
                        else
                            llist += "," + langList.Items[gcnt].ToString();
                    }

                    con.Open();

                    cmdnewdb = new MySqlCommand("update skills set proglist=@plst,cmslist=@clst,oslist=@olst,fieldlist=@flst,langlist=@llst where studi=@sid", con);

                    cmdnewdb.Parameters.AddWithValue("sid", sid);
                    cmdnewdb.Parameters.AddWithValue("plst", plist);
                    cmdnewdb.Parameters.AddWithValue("clst", clist);
                    cmdnewdb.Parameters.AddWithValue("olst", olist);
                    cmdnewdb.Parameters.AddWithValue("flst", flist);
                    cmdnewdb.Parameters.AddWithValue("llst", llist);

                    cmdnewdb.ExecuteNonQuery();
                    MessageBox.Show("Kwowledge and Skills Details Updated Succesfully", "Update Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmdnewdb.Parameters.Clear();

                    con.Close();

                    clearControls(sender, e);

                }
                catch (Exception err)
                {
                    MessageBox.Show("There is a problem with input values. Please provide valid inputs.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CreateLogFile Err = new CreateLogFile();
                    Err.ErrorLog("ErrorLog", "Update method of StudentKwSkills Page :" + err.Message);
                }//End of Catch
            }//End of Outer If-Else
        }
        private void bUpdate_Click(object sender, EventArgs e)
        {
            if (studstat.Text == "" || tfname.Text == "" || tmname.Text == "" || size.Text == "" || pdesc.Text == "" || tcname.Text == "" || istatus.Text == "" || title.Text == "")
            {
                MessageBox.Show("Please fill in all the fields before updating.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    con.Open();

                    cmdnewdb = new MySqlCommand("update internship set status=@st,cname=@name,mgrname=@mgr,facname=@fac,title=@head,size=@tot,istatus=@istat,pdesc=@desc where studid=@sd", con);
                    cmdnewdb.Parameters.AddWithValue("sd", sid);
                    cmdnewdb.Parameters.AddWithValue("st", studstat.SelectedItem.ToString());
                    cmdnewdb.Parameters.AddWithValue("name", tcname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("mgr", tmname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("fac", tfname.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("head", title.Text.Trim());
                    cmdnewdb.Parameters.AddWithValue("tot", int.Parse(size.Text));
                    cmdnewdb.Parameters.AddWithValue("istat", istatus.SelectedItem.ToString());
                    cmdnewdb.Parameters.AddWithValue("desc", pdesc.Text.Trim());

                    cmdnewdb.ExecuteNonQuery();
                    MessageBox.Show("Internship Details Updated Succesfully", "Update Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmdnewdb.Parameters.Clear();
                    con.Close();
                }
                catch (Exception err)
                {
                    MessageBox.Show("Problem may be due to incorrect ID. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CreateLogFile Err = new CreateLogFile();
                    Err.ErrorLog("ErrorLog", "Update method of Student Internship Page :" + err.Message);
                }
            }
        }
Example #19
0
        private void bUpdate_Click(object sender, EventArgs e)
        {
            int status;
            try
            {
                con.Open();
                cmdnewdb = new MySqlCommand("update interest set fieldlist=@flst,loclist=@llst,comments=@com where studid=@id", con);
                cmdnewdb.Parameters.AddWithValue("id", sid);
                cmdnewdb.Parameters.AddWithValue("flst", fieldList.Text);
                cmdnewdb.Parameters.AddWithValue("llst", locList.Text);
                cmdnewdb.Parameters.AddWithValue("com", comments.Text);

                status = cmdnewdb.ExecuteNonQuery();

                if (status > 0)
                {
                    MessageBox.Show("Interest Details Updated Succesfully", "Updated Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No records found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                cmdnewdb.Parameters.Clear();
                con.Close();
                clearControls(sender, e);
            }
            catch (Exception err)
            {
                MessageBox.Show("Problem may be: Database Connection doe not exist. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CreateLogFile Err = new CreateLogFile();
                Err.ErrorLog("ErrorLog", "Update method of Student Interest Page :" + err.Message);
            }
        }