Пример #1
0
    public void addWorkExp(worker.workExperience workExp)
    {
        SqlCommand cmd = new SqlCommand();

        try
        {
            cmd.CommandText = "saveWorkExp";
            cmd.Connection  = utility.getConn();
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@id", workExp.ID);
            cmd.Parameters.AddWithValue("@company", workExp.company);
            cmd.Parameters.AddWithValue("@empid", recid);
            cmd.Parameters.AddWithValue("@jobtitle", workExp.jobtitle);
            cmd.Parameters.AddWithValue("@frDate", workExp.frDate);
            cmd.Parameters.AddWithValue("@toDate", workExp.toDate);
            cmd.Parameters.AddWithValue("@comment", workExp.comment);

            cmd.Connection.Open();
            cmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            throw new Exception("Error occurred:" + ex.Message);
        }
        finally
        {
            cmd.Connection.Close();
        }
    }
Пример #2
0
    public List <worker.workExperience> workHistory()
    {
        List <worker.workExperience> wHistory = new List <worker.workExperience>();
        SqlCommand cmd = new SqlCommand();

        try
        {
            cmd.Connection = utility.getConn();
            cmd.Connection.Open();

            cmd.CommandText = "select * from tblEmpWorkExp where empid=" + recid + " order by frDate DESC";

            SqlDataReader dbread = cmd.ExecuteReader();
            while (dbread.Read())
            {
                worker.workExperience tmp = new worker.workExperience();
                tmp.ID       = Convert.ToInt32(dbread["ID"]);
                tmp.company  = Convert.ToString(dbread["company"]);
                tmp.jobtitle = Convert.ToString(dbread["jobtitle"]);
                tmp.frDate   = Convert.ToDateTime(dbread["frDate"]);
                tmp.toDate   = Convert.ToDateTime(dbread["toDate"]);
                tmp.comment  = Convert.ToString(dbread["comment"]);

                wHistory.Add(tmp);
            }
            dbread.Close();
        }
        finally
        {
            cmd.Connection.Close();
        }
        return(wHistory);
    }