Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="moment">время наступления события</param>
        /// <param name="type">Тип события</param>
        /// <param name="info"></param>
        public void WriteActivityMessage(DateTime moment, ActivityType type, Dictionary <string, string> info)//(string requiredPage, string userName, DateTime moment, string userHostAddress, string queryString, string userMachineName, string userAgent)
        {
            StringBuilder comment = new StringBuilder();

            try
            {
                var newId = dbu.ExecuteScalarQuery("INSERT INTO ActivityMonitor(Moment, Type)  VALUES(@moment, @type)  SELECT SCOPE_IDENTITY()", new Dictionary <string, object>()
                {
                    { "@moment", moment.ToString("yyyy-MM-dd HH:mm:ss") },
                    { "@type", Enum.GetName(typeof(ActivityType), type) }
                });
                if (newId != null)
                {
                    int id = Decimal.ToInt32((Decimal)newId);
                    foreach (var key in info.Keys)
                    {
                        dbu.ExecuteNonQuery(string.Format("INSERT INTO ActivityMonitorValues(ParentId, Property, Value)  VALUES('{0}', '{1}', '{2}')", id.ToString(), key, info[key]), null, null);
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingUtils.DefaultLogger.AddLogMessage(null, MessageType.Error, "Error Operation Insert In SQL, Moment=" + moment.ToString("yyyy-MM-dd HH:mm:ss") + ", Type=" + Enum.GetName(typeof(ActivityType), type), ex.GetType(), ex.Message);
            }
        }
Exemplo n.º 2
0
 public void Insert(Aluno aluno)
 {
     try
     {
         string query = "INSERT INTO tbAluno(codAluno, biometria) VALUES(@codAluno, @biometria)";
         dbUtils.ExecuteNonQuery(query, new MySqlParameter("@codAluno", aluno.CodAluno),
                                 new MySqlParameter("@biometria", aluno.Biometria));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
         dbUtils.FecharConexao();
     }
 }
Exemplo n.º 3
0
 public void Insert(Mesa mesa)
 {
     try
     {
         string query = "INSERT INTO tbMesa(codAluno, hrRetirada) VALUES(@codAluno, @hrRetirada)";
         dbUtils.ExecuteNonQuery(query, new MySqlParameter("@codAluno", mesa.CodAluno),
                                 new MySqlParameter("@hrRetirada", mesa.HrRetirada));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
         dbUtils.FecharConexao();
     }
 }
Exemplo n.º 4
0
 //删除对应表名和ID的项
 private bool dbPrdctTestDelete(string idSel)
 {
     try
     {
         string sqlDel = string.Format("delete from ProductTest where Id={0}", idSel);
         return(DatabaseUtils.ExecuteNonQuery(sqlDel) > 0);
     }
     catch (Exception ex)
     {
         Logger.Error(MethodBase.GetCurrentMethod(), "删除盐雾试验记录:" + ex.Message);
         return(false);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// 修改对应ID和字段的试验数据
 /// </summary>
 /// <param name="idSel"></param>
 /// <returns></returns>
 private bool dbPrdctTestUpd_Prop(string propName, string propValue, string idSel)
 {
     if (string.IsNullOrEmpty(propName) || string.IsNullOrEmpty(propValue) || string.IsNullOrEmpty(idSel))
     {
         return(false);
     }
     try
     {
         string sqlDel = string.Format("update ProductTest set {0}='{1}' where Id={2}", propName, propValue, idSel);
         return(DatabaseUtils.ExecuteNonQuery(sqlDel) > 0);
     }
     catch (Exception ex)
     {
         Logger.Error(MethodBase.GetCurrentMethod(), "删除盐雾试验记录:" + ex.Message);
         return(false);
     }
 }
Exemplo n.º 6
0
 private void btnOk_Click(object sender, RoutedEventArgs e)
 {
     if (!validateInput())
     {
         return;                  //判断输入是否合法
     }
     try
     {
         this.setProperties();       //设置属性值
         if (this.mpt.EditFlag == 1) //添加
         {
             string sql = string.Format("insert into ProductTest(ProductId,StartTime,WeLossTime,ReLossTime,WeEndTime,ReEndTime," +
                                        "WeTestResult,ReTestResult,Remark) values({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", mpt.PrdctId,
                                        mpt.StartTime, mpt.WeLossTime, mpt.ReLossTime, mpt.WeEndTime, mpt.ReEndTime, mpt.WeTestResult, mpt.ReTestResult, mpt.Remark);
             if (DatabaseUtils.ExecuteNonQuery(sql) > 0)
             {
                 this.Refurbish(this.mpt);
                 this.DialogResult = true;
             }
             else
             {
                 System.Windows.MessageBox.Show("添加失败!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
             }
         }
         else if (this.mpt.EditFlag == 2)//修改
         {
             string sql = string.Format("update ProductTest set ProductId={0},StartTime='{1}',WeLossTime='{2}',ReLossTime='{3}'," +
                                        "WeEndTime='{4}',ReEndTime='{5}',WeTestResult='{6}',ReTestResult='{7}',Remark='{8}' where Id={9}", mpt.PrdctId, mpt.StartTime,
                                        mpt.WeLossTime, mpt.ReLossTime, mpt.WeEndTime, mpt.ReEndTime, mpt.WeTestResult, mpt.ReTestResult, mpt.Remark, mpt.Id);
             if (DatabaseUtils.ExecuteNonQuery(sql) > 0)
             {
                 this.Refurbish(this.mpt);
                 this.DialogResult = true;
             }
             else
             {
                 System.Windows.MessageBox.Show("修改失败!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Error(MethodBase.GetCurrentMethod(), "修改产品试验数据异常:" + ex.Message);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// 操作数据库(修改产品属性)
        /// </summary>
        public void SaveProperty()
        {
            if (!this.updatableFlag)
            {
                return;
            }
            try
            {
                switch (EditState)
                {
                case EditState.New:
                    //新增
                    string sqlNew = string.Format("INSERT INTO ProductData(PrdctNumber,PrdctName,Industry,TreatType,WeDuration,ReDuration,Remark)"
                                                  + " VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", this.PrdctNumber, this.PrdctName, this.Industry, this.TreatType,
                                                  this.WeDuration, this.ReDuration, this.Remark);
                    DatabaseUtils.ExecuteNonQuery(sqlNew);
                    break;

                case EditState.Deleted:
                    //删除
                    string sqlDel = string.Format("delete from ProductData where Id={0}", this.Id);
                    DatabaseUtils.ExecuteNonQuery(sqlDel);
                    break;

                case EditState.Modified:
                    //修改
                    string sqlUpd = string.Format("UPDATE ProductData SET PrdctNumber='{0}',PrdctName='{1}',Industry='{2}',TreatType='{3}',"
                                                  + "WeDuration='{4}',ReDuration='{5}',Remark='{6}' WHERE Id={7}", this.PrdctNumber, this.PrdctName, this.Industry,
                                                  this.TreatType, this.WeDuration, this.ReDuration, this.Remark, this.Id);
                    DatabaseUtils.ExecuteNonQuery(sqlUpd);
                    break;
                }
            }
            catch (Exception ex)
            {
                //Logger.Error(MethodBase.GetCurrentMethod(), "产品基础资料管理错误:" + ex.Message);
                throw ex;
            }
        }