Ejemplo n.º 1
0
        /// <summary>
        /// save it to database
        /// </summary>
        /// <param name="sug"></param>
        /// <returns></returns>
        public bool saveSug(csSuggestion sug)
        {
            bool          result = false;
            SqlConnection db     = new SqlConnection(connectionString);

            db.Open();
            SqlCommand cmd = new SqlCommand("InsertSuggestion", db);

            try
            {
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@dt", SqlDbType.DateTime);
                cmd.Parameters["@dt"].Value = sug.dt;
                cmd.Parameters.Add("@id", SqlDbType.VarChar);
                cmd.Parameters["@id"].Value = sug.senderId;
                cmd.Parameters.Add("@msg", SqlDbType.VarChar);
                cmd.Parameters["@msg"].Value = sug.message;

                result = (cmd.ExecuteNonQuery() == 1);
                cmd.Dispose();
                db.Close();
                db.Dispose();
            }
            catch (Exception e)
            {
                tofile.WriteTxt(e.Message);
                cmd.Dispose();
                db.Close();
                db.Dispose();
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// save it to database
        /// </summary>
        /// <param name="sug"></param>
        /// <returns></returns>
        public bool saveSug(csSuggestion sug)
        {
            bool result = false;
            SqlConnection db = new SqlConnection(connectionString);
            db.Open();
            SqlCommand cmd = new SqlCommand("InsertSuggestion", db);
            try
            {
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@dt", SqlDbType.DateTime);
                cmd.Parameters["@dt"].Value = sug.dt;
                cmd.Parameters.Add("@id", SqlDbType.VarChar);
                cmd.Parameters["@id"].Value = sug.senderId;
                cmd.Parameters.Add("@msg", SqlDbType.VarChar);
                cmd.Parameters["@msg"].Value = sug.message;

                result = (cmd.ExecuteNonQuery() == 1);
                cmd.Dispose();
                db.Close();
                db.Dispose();
            }
            catch (Exception e)
            {
                tofile.WriteTxt(e.Message);
                cmd.Dispose();
                db.Close();
                db.Dispose();
            }
            return result;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Save the suggestion in a plain txt
        /// </summary>
        /// <param name="sug"></param>
        /// <param name="bTxt"></param>
        /// <returns></returns>
        public bool saveSug(csSuggestion sug, bool bTxt)
        {
            StringBuilder sb = new System.Text.StringBuilder();

            sb.Append(sug.dt.ToString() + ", 发送人:" + sug.senderId + ", 建议:" + sug.message + "\r\n");
            return(tofile.WriteTxt(sb.ToString(), SuggestionLog));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Save the suggestion in a plain txt
 /// </summary>
 /// <param name="sug"></param>
 /// <param name="bTxt"></param>
 /// <returns></returns>
 public bool saveSug(csSuggestion sug, bool bTxt)
 {
     StringBuilder sb = new System.Text.StringBuilder();
     sb.Append(sug.dt.ToString() + ", 发送人:" +sug.senderId + ", 建议:" + sug.message + "\r\n") ;
     return tofile.WriteTxt(sb.ToString(), SuggestionLog);
 }