Beispiel #1
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns></returns>
 public int Add(ParameterValue entity)
 {
     try
     {
         entity.Status = "1";
         if (dr == null)
         {
             dr = new CallDatabase();
         }
         dr.InitiCommand("insert into Sys_ParameterValue([P_Id],[Value],[No],[Memo])values(@P_Id,@Value,@No,@Memo);select @@identity");
         dr.AddParameters("P_Id", DbType.Int32, entity.P_Id);
         dr.AddParameters("Value", DbType.String, 60, entity.Value);
         dr.AddParameters("No", DbType.Int32, entity.No);
         dr.AddParameters("Memo", DbType.String, 300, entity.Memo);
         int value = Convert.ToInt32(dr.ExecuteScalar());
         entity.Id = value;
         dr.Close();
         return(0);
     }
     catch (Exception ex)
     {
         using (ILog_Error log = new Log_Error_Generate())
         {
             log.Title   = ex.Message;
             log.Content = ex.StackTrace;
             log.Generatelog();
         }
         return(-1);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns></returns>
 public int Add(System_User entity)
 {
     try
     {
         if (dr == null)
         {
             dr = new CallDatabase();
         }
         dr.InitiCommand("insert into Sys_User([LoginName],[Pwd],[UserName],[Remarks])values(@LoginName,@Pwd,@UserName,@Remarks);select @@identity");
         dr.AddParameters("LoginName", DbType.String, 30, entity.LoginName);
         dr.AddParameters("Pwd", DbType.String, 20, entity.Pwd);
         dr.AddParameters("UserName", DbType.String, 8, entity.UserName);
         dr.AddParameters("Remarks", DbType.String, 200, entity.Remarks);
         int value = Convert.ToInt32(dr.ExecuteScalar());
         entity.Id = value;
         dr.Close();
         return(0);
     }
     catch (Exception ex)
     {
         using (ILog_Error log = new Log_Error_Generate())
         {
             log.Title   = ex.Message;
             log.Content = ex.StackTrace;
             log.Generatelog();
         }
         return(-1);
     }
 }
Beispiel #3
0
        /// <summary>
        /// 处理非UI线程异常
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception ex = (Exception)e.ExceptionObject;

            using (ILog_Error log = new Log_Error_Generate())
            {
                log.Title   = ex.Message;
                log.Content = ex.StackTrace;
                log.Generatelog();
                MessageBox.Show(ex.Message, "错误提示");
            }
        }
Beispiel #4
0
        /// <summary>
        /// 处理UI线程异常
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            var error = e.Exception;

            using (ILog_Error log = new Log_Error_Generate())
            {
                log.Title   = error.Message;
                log.Content = error.StackTrace;
                log.Generatelog();
                MessageBox.Show(error.Message, "错误提示");
            }
        }
Beispiel #5
0
 /// <summary>
 /// 实体列表
 /// </summary>
 /// <returns>返回实体列表</returns>
 public string QueryData()
 {
     try
     {
         if (File.Exists(UrlPath))
         {
             return(File.ReadAllText(UrlPath));
         }
         else
         {
             return("[]");
         }
     }
     catch (Exception ex)
     {
         using (ILog_Error log = new Log_Error_Generate())
         {
             log.Title   = ex.Message;
             log.Content = ex.StackTrace;
             log.Generatelog();
         }
         return("[]");
     }
 }
Beispiel #6
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public int Add(Expend entity)
        {
            if (dr == null)
            {
                dr = new CallDatabase();
            }
            int value = -1;

            try
            {
                dr.InitiCommand("insert into Expend([ExpendDate],[Year_Date],[Month_Date],[Day_Date],[ExpendType],[ItemName],[Amount],[Reason],[Remarks])values(@ExpendDate,@Year_Date,@Month_Date,@Day_Date,@ExpendType,@ItemName,@Amount,@Reason,@Remarks);SELECT @@IDENTITY;");
                dr.AddParameters("ExpendDate", DbType.DateTime, entity.ExpendDate);
                dr.AddParameters("Year_Date", DbType.String, 20, entity.Year_Date);
                dr.AddParameters("Month_Date", DbType.String, 20, entity.Month_Date);
                dr.AddParameters("Day_Date", DbType.Int32, entity.Day_Date);
                dr.AddParameters("ExpendType", DbType.String, 50, entity.ExpendType);
                dr.AddParameters("ItemName", DbType.String, 72, entity.ItemName);
                dr.AddParameters("Amount", DbType.Decimal, entity.Amount);
                dr.AddParameters("Reason", DbType.String, 250, entity.Reason);
                dr.AddParameters("Remarks", DbType.String, 500, entity.Remarks);
                object id = dr.ExecuteScalar();
                entity.Id = Convert.ToInt32(id);
                value     = 1;
            }
            catch (Exception ex)
            {
                using (ILog_Error log = new Log_Error_Generate())
                {
                    log.Title   = ex.Message;
                    log.Content = ex.StackTrace;
                    log.Generatelog();
                }
                value = -1;
            }
            return(value);
        }