Пример #1
0
        public static List <jpprofile> Getjpprofile(string whereclause, MySqlConnection conn = null)
        {
            jpprofile        objjpprofile = null;
            List <jpprofile> lstjpprofile = new List <jpprofile>();

            try
            {
                bool            isConnArgNull = (conn != null) ? false : true;
                MySqlConnection connection    = (conn != null) ? conn : PrimaryConnection();
                tryOpenConnection(connection);
                string sql = "select * from jpprofile ";
                if (!string.IsNullOrEmpty(whereclause))
                {
                    sql += " where " + whereclause;
                }
                using (MySqlCommand command = new MySqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandText = sql;
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                objjpprofile = ReaderDatajpprofile(reader);
                                lstjpprofile.Add(objjpprofile);
                            }
                        }
                        else
                        {
                        }
                    }
                }

                if (isConnArgNull == true)
                {
                    connection.Dispose();
                }
            }
            catch (Exception ex)
            {
                Logger._log.Error(ex.Message + "\n" + ex.StackTrace);
            }

            return(lstjpprofile);
        }
Пример #2
0
        private static jpprofile ReaderDatajpprofile(MySqlDataReader reader)
        {
            jpprofile objjpprofile = new jpprofile();

            objjpprofile.PROFILEID       = Utility.IsValidInt(reader["PROFILEID"]);
            objjpprofile.NAME            = Utility.IsValidString(reader["NAME"]);
            objjpprofile.ADDRESS         = Utility.IsValidString(reader["ADDRESS"]);
            objjpprofile.DOB             = Utility.IsValidDateTime(reader["DOB"]);
            objjpprofile.GENDER          = Utility.IsValidString(reader["GENDER"]);
            objjpprofile.CONTACT         = Utility.IsValidString(reader["CONTACT"]);
            objjpprofile.PROFILEBIO      = Utility.IsValidString(reader["PROFILEBIO"]);
            objjpprofile.USERID          = Utility.IsValidInt(reader["USERID"]);
            objjpprofile.CURRENTSALARY   = Utility.IsValidString(reader["CURRENTSALARY"]);
            objjpprofile.LONGCV          = Utility.IsValidString(reader["LONGCV"]);
            objjpprofile.CURRENTCURRENCY = Utility.IsValidString(reader["CURRENTCURRENCY"]);
            objjpprofile.NATIONALITY     = Utility.IsValidString(reader["NATIONALITY"]);
            objjpprofile.LANGUAGE        = Utility.IsValidString(reader["LANGUAGE"]);

            return(objjpprofile);
        }
Пример #3
0
        public static string Savejpprofile(jpprofile objjpprofile, MySqlConnection conn = null, MySqlTransaction trans = null)
        {
            string returnMessage = "";
            string sPROFILEID    = "";

            sPROFILEID = objjpprofile.PROFILEID.ToString();
            var templstjpprofile = Getjpprofile("PROFILEID = '" + sPROFILEID + "'", conn);

            try
            {
                bool            isConnArgNull = (conn != null) ? false : true;
                MySqlConnection connection    = (conn != null) ? conn : PrimaryConnection();
                tryOpenConnection(connection);
                using (MySqlCommand command = new MySqlCommand())
                {
                    string sql;
                    bool   isEdit = true;
                    if (templstjpprofile.Count <= 0)
                    {
                        isEdit = false;
                        sql    = @"INSERT INTO jpprofile(
NAME,
ADDRESS,
DOB,
GENDER,
CONTACT,
PROFILEBIO,
USERID,
CURRENTSALARY,
LONGCV,

NATIONALITY,
LANGUAGE,
CURRENTCURRENCY
)
VALUES(
@NAME,
@ADDRESS,
@DOB,
@GENDER,
@CONTACT,
@PROFILEBIO,
@USERID,
@CURRENTSALARY,
@LONGCV,
@NATIONALITY,
@LANGUAGE,
@CURRENTCURRENCY
)";
                    }
                    else
                    {
                        sql = @"Update jpprofile set
PROFILEID=@PROFILEID,
NAME=@NAME,
ADDRESS=@ADDRESS,
DOB=@DOB,
GENDER=@GENDER,
CONTACT=@CONTACT,
PROFILEBIO=@PROFILEBIO,
USERID=@USERID,
CURRENTSALARY=@CURRENTSALARY,
LONGCV=@LONGCV,
NATIONALITY=@NATIONALITY,
LANGUAGE=@LANGUAGE,
CURRENTCURRENCY=@CURRENTCURRENCY
Where PROFILEID=@PROFILEID";
                    }
                    if (trans != null)
                    {
                        command.Transaction = trans;
                    }
                    command.Connection = connection;

                    //command.CommandText = "SET GLOBAL max_allowed_packet=32*1024*1024;";
                    //command.ExecuteNonQuery();

                    command.CommandType = CommandType.Text;
                    command.CommandText = sql;
                    if (isEdit)
                    {
                        command.Parameters.AddWithValue("@PROFILEID", objjpprofile.PROFILEID);
                    }

                    command.Parameters.AddWithValue("@NAME", objjpprofile.NAME);
                    command.Parameters.AddWithValue("@ADDRESS", objjpprofile.ADDRESS);
                    command.Parameters.AddWithValue("@DOB", objjpprofile.DOB);
                    command.Parameters.AddWithValue("@GENDER", objjpprofile.GENDER);
                    command.Parameters.AddWithValue("@CONTACT", objjpprofile.CONTACT);
                    command.Parameters.AddWithValue("@PROFILEBIO", objjpprofile.PROFILEBIO);
                    command.Parameters.AddWithValue("@USERID", objjpprofile.USERID);
                    command.Parameters.AddWithValue("@CURRENTSALARY", objjpprofile.CURRENTSALARY);
                    command.Parameters.AddWithValue("@LONGCV", objjpprofile.LONGCV);
                    command.Parameters.AddWithValue("@LANGUAGE", objjpprofile.LANGUAGE);
                    command.Parameters.AddWithValue("@NATIONALITY", objjpprofile.NATIONALITY);
                    command.Parameters.AddWithValue("@CURRENTCURRENCY", objjpprofile.CURRENTCURRENCY);
                    // command.Parameters.AddWithValue("@EMAIL", objjpprofile.EMAIL);
                    int affectedRows = command.ExecuteNonQuery();
                    if (affectedRows > 0)
                    {
                        returnMessage = "OK";
                    }
                    else
                    {
                        returnMessage = Constants.MSG_ERR_DBSAVE.Text;
                    }
                }

                if (isConnArgNull == true)
                {
                    connection.Dispose();
                }
            }
            catch (Exception ex)
            {
                Logger._log.Error(ex.Message + "\n" + ex.StackTrace);
            }

            return(returnMessage);
        }