/// <summary> /// Insert data /// </summary> /// <param name="dataInsert"></param> /// <param name="tableName"></param> /// <returns></returns> /// public bool InsertData(Object dataInsert, string tableName) { _logger.Start("InsertData"); _logger.Param("TableName", tableName); bool result = false; try { sqlMap.BeginTransaction(); Hashtable param = new Hashtable(); #region Tao du lieu cho values de import ArrayList arrValues = new ArrayList(); ArrayList arrColumns = new ArrayList(); this.SetDataToArrayListForInsert(dataInsert, ref arrColumns, ref arrValues); #endregion //ten table param.Add("tablename", tableName); //Cac column trong table param.Add("columns", arrColumns); //gia tri cua cac du lieu can insert param.Add("values", arrValues); sqlMap.Insert("Common.InsertRow", param); //commit du lieu sqlMap.CommitTransaction(); //them moi du lieu thanh cong result = true; } catch (Exception ex) { sqlMap.RollbackTransaction(); _logger.Error(ex); } _logger.End("InsertData"); return(result); }
/// <summary> /// Constructor with sqlConfig file. /// </summary> /// <param name="sqlMapConfig">SQLConfig file</param> public SQLMapEmployee(string sqlMapConfig) { logger.Start("Constructor SQLMap - Map du lieu"); try { logger.Param("Loi kết nối tới database", sqlMapConfig); //create SQLMapper from SQLConfig file this.str_SqlMapConfig = sqlMapConfig; DomSqlMapBuilder cDom = new DomSqlMapBuilder(); sqlMapEmployee = (SqlMapper)cDom.Configure(sqlMapConfig); sqlMapEmployee.DataSource.ConnectionString = "Data Source=10.84.0.31;Initial Catalog=MixHRM_2017;User ID= HRM;Password=HRm11@122";//EncryptData(sqlMapEmployee.DataSource.ConnectionString); logger.Info("Creating SQLMapper sucessfull"); } catch (SqlException ex) { logger.Error(ex.ToString()); } logger.End("Constructor SQLMap"); }
/// <summary> /// Constructor with sqlConfig file. /// </summary> /// <param name="sqlMapConfig">SQLConfig file</param> public SQLMap(string sqlMapConfig) { logger.Start("Constructor SQLMap - Map du lieu"); try { logger.Param("Loi kết nối tới database", sqlMapConfig); //create SQLMapper from SQLConfig file this.str_SqlMapConfig = sqlMapConfig; DomSqlMapBuilder cDom = new DomSqlMapBuilder(); sqlMap = (SqlMapper)cDom.Configure(sqlMapConfig); sqlMap.DataSource.ConnectionString = EncryptData(sqlMap.DataSource.ConnectionString); logger.Info("Creating SQLMapper sucessfull"); } catch (SqlException ex) { logger.Error(ex.ToString()); } logger.End("Constructor SQLMap"); }