Пример #1
0
        /// <summary>
        /// 修改資料
        /// </summary>
        /// <param name="formdata"></param>
        /// <returns></returns>
        public static bool ToUptForm1Data(Form1Data formdata)
        {
            bool result = false;

            using (var conn = new SqlConnection(MainController.connStr))
            {
                conn.Open();
                //SqlTransaction sqlTrans = conn.BeginTransaction();
                try
                {
                    string sqlStr = @"UPDATE dt_formdata SET Title = @dc_title, File_Info = @dc_fileinfo WHERE ID = @dc_ID";
                    conn.Execute(sqlStr, new { dc_title = formdata.Title, dc_fileinfo = formdata.File_Info, dc_ID = formdata.ID });
                    result = true;
                }
                catch (Exception err)
                {
                    throw (err);
                }
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        /// 新增資料
        /// </summary>
        /// <param name="formdata"></param>
        /// <returns></returns>
        public static bool ToInsForm1Data(Form1Data formdata)
        {
            bool result = false;

            using (var conn = new SqlConnection(MainController.connStr))
            {
                try
                {
                    conn.Open();
                    string sqlStr = @"INSERT INTO dt_formdata (Title, File_Info, Create_Time) VALUES (@dc_title, @dc_fileinfo,  CURRENT_TIMESTAMP)";
                    conn.Execute(sqlStr, new[] {
                        new { dc_title = formdata.Title, dc_fileinfo = formdata.File_Info }
                    });

                    result = true;
                }
                catch (Exception err)
                {
                    throw (err);
                }
            }
            return(result);
        }