Esempio n. 1
0
 public Designation GetDesignation(int designationId)
 {
     try
     {
         SqlConnectionObj.Open();
         string query = String.Format("SELECT * FROM tbl_Designation WHERE Id='{0}'", designationId);
         SqlCommandObj.CommandText = query;
         SqlDataReader reader = SqlCommandObj.ExecuteReader();
         Designation aDesignation = new Designation();
         while (reader.Read())
         {
             aDesignation.Id = Convert.ToInt32(reader["Id"]);
             aDesignation.Code = reader["Code"].ToString();
             aDesignation.Title = reader["Title"].ToString();
         }
         
         return aDesignation;
     }
     catch (Exception ex)
     {
         throw new Exception("Designation couldn't loaded from your system", ex);
     }
     finally
     {
         if (SqlConnectionObj != null && SqlConnectionObj.State == ConnectionState.Open)
         {
             SqlConnectionObj.Close();
         }
     }
 }
        public bool Save(Designation aDesignation, out string saveMessage)
        {
            if (aDesignation.Code == string.Empty)
            {
                saveMessage = "Designation code missing";
                return false;

            }
            else if (aDesignation.Title == string.Empty)
            {
                saveMessage = "Designation title missing";
                return false;
            }
            else if (designationGateway.HasThisDesignationCode(aDesignation.Code))
            {
                saveMessage = "Your system already has this designation code. Try again.";
                return false;
            }
            else if (designationGateway.HasThisDesignationTitle(aDesignation.Title))
            {
                saveMessage = "Your system already has this designation title. Try again.";
                return false;
            }
            else
            {
                saveMessage = "Designation has been saved.";
                return designationGateway.Save(aDesignation);
            }
        }
Esempio n. 3
0
        public List<Designation> GetAll()
        {
            List<Designation> designations = new List<Designation>();
            try
            {
                SqlConnectionObj.Open();
                string query = String.Format("SELECT * FROM tbl_Designation");
                SqlCommandObj.CommandText = query;
                SqlDataReader readerObj = SqlCommandObj.ExecuteReader();
                while (readerObj.Read())
                {
                    Designation aDesignation = new Designation();
                    aDesignation.Id = Convert.ToInt32(readerObj["Id"]);
                    aDesignation.Code = readerObj["Code"].ToString();
                    aDesignation.Title = readerObj["Title"].ToString();
                    designations.Add(aDesignation);
                }

            }
            catch (Exception ex)
            {
                throw new Exception("Designation couldn't loaded from your system", ex);
            }
            finally
            {
                if (SqlConnectionObj != null && SqlConnectionObj.State == ConnectionState.Open)
                {
                    SqlConnectionObj.Close();
                }
            }
            return designations;
        }
 public Designation GetDesignation(int designationId)
 {
     SqlConnectionObj.Open();
     string query = String.Format("SELECT * FROM tbl_Designation WHERE Id='{0}'", designationId);
     SqlCommandObj.CommandText = query;
     SqlDataReader reader = SqlCommandObj.ExecuteReader();
     Designation aDesignation = new Designation();
     while (reader.Read())
     {
         aDesignation.Id = Convert.ToInt32(reader["Id"]);
         aDesignation.Code = reader["Code"].ToString();
         aDesignation.Title = reader["Title"].ToString();
     }
     SqlConnectionObj.Close();
     return aDesignation;
 }
 public List<Designation> GetAll()
 {
     List<Designation> designations = new List<Designation>();
     SqlConnectionObj.Open();
     string query = String.Format("SELECT * FROM tbl_Designation");
     SqlCommandObj.CommandText = query;
     SqlDataReader readerObj = SqlCommandObj.ExecuteReader();
     while (readerObj.Read())
     {
         Designation aDesignation = new Designation();
         aDesignation.Id = Convert.ToInt32(readerObj["Id"]);
         aDesignation.Code = readerObj["Code"].ToString();
         aDesignation.Title = readerObj["Title"].ToString();
         designations.Add(aDesignation);
     }
     SqlConnectionObj.Close();
     return designations;
 }
Esempio n. 6
0
 public bool Save(Designation aDesignation)
 {
     try
     {
         SqlConnectionObj.Open();
         string query = String.Format("INSERT INTO tbl_Designation VALUES('{0}','{1}')", aDesignation.Code,
                                      aDesignation.Title);
         SqlCommandObj.CommandText = query;
         SqlCommandObj.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
        throw new Exception("Designation couldn't saved",ex);
     }
     finally
     {
         if (SqlConnectionObj != null && SqlConnectionObj.State == ConnectionState.Open)
         {
             SqlConnectionObj.Close();
         }
     }
     return true;
 }
 public bool Save(Designation aDesignation)
 {
     SqlConnectionObj.Open();
     string query = String.Format("INSERT INTO tbl_Designation VALUES('{0}','{1}')", aDesignation.Code,
         aDesignation.Title);
     SqlCommandObj.CommandText = query;
     SqlCommandObj.ExecuteNonQuery();
     SqlConnectionObj.Close();
     return true;
 }