public bool AddMOccupation(MOccupation moccupation) { SqlCommand cmd; cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "AddMOccupation"; cmd.Parameters.AddWithValue("@OccupationNo", moccupation.OccupationNo); cmd.Parameters.AddWithValue("@OccupationName", moccupation.OccupationName); cmd.Parameters.AddWithValue("@ShortName", moccupation.ShortName); cmd.Parameters.AddWithValue("@IsActive", moccupation.IsActive); cmd.Parameters.AddWithValue("@UserID", moccupation.UserID); cmd.Parameters.AddWithValue("@UserDate", moccupation.UserDate); cmd.Parameters.AddWithValue("@CompanyNo", moccupation.CompanyNo); if (ObjTrans.ExecuteNonQuery(cmd, CommonFunctions.ConStr) == true) { return(true); } else { moccupation.msg = ObjTrans.ErrorMessage; return(false); } }
public MOccupation ModifyMOccupationByID(long ID) { SqlConnection Con = new SqlConnection(CommonFunctions.ConStr); string sql; SqlCommand cmd; sql = "Select * from MOccupation where OccupationNo =" + ID; cmd = new SqlCommand(sql, Con); cmd.Connection = Con; Con.Open(); cmd.CommandType = CommandType.Text; SqlDataReader dr; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (dr.HasRows) { MOccupation MM = new MOccupation(); while (dr.Read()) { MM.OccupationNo = Convert.ToInt32(dr["OccupationNo"]); if (!Convert.IsDBNull(dr["OccupationName"])) { MM.OccupationName = Convert.ToString(dr["OccupationName"]); } if (!Convert.IsDBNull(dr["ShortName"])) { MM.ShortName = Convert.ToString(dr["ShortName"]); } if (!Convert.IsDBNull(dr["IsActive"])) { MM.IsActive = Convert.ToBoolean(dr["IsActive"]); } if (!Convert.IsDBNull(dr["UserID"])) { MM.UserID = Convert.ToInt64(dr["UserID"]); } if (!Convert.IsDBNull(dr["UserDate"])) { MM.UserDate = Convert.ToDateTime(dr["UserDate"]); } if (!Convert.IsDBNull(dr["ModifiedBy"])) { MM.ModifiedBy = Convert.ToString(dr["ModifiedBy"]); } if (!Convert.IsDBNull(dr["CompanyNo"])) { MM.CompanyNo = Convert.ToInt64(dr["CompanyNo"]); } } dr.Close(); return(MM); } else { dr.Close(); } return(new MOccupation()); }
public bool DeleteMOccupation(MOccupation moccupation) { SqlCommand cmd; cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "DeleteMOccupation"; cmd.Parameters.AddWithValue("@OccupationNo", moccupation.OccupationNo); if (ObjTrans.ExecuteNonQuery(cmd, CommonFunctions.ConStr) == true) { return(true); } else { moccupation.msg = ObjTrans.ErrorMessage; return(false); } }