示例#1
0
        /// <summary>
        /// 保存数据(数据较少情况下)
        /// </summary>
        /// <param name="dataSet"></param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public bool SaveDataToTable(DataSet dataSet, string tableName)
        {
            string strSql = "select * from " + "[" + tableName + "]";

            try
            {
                if (!dataSet.HasChanges())
                {
                    return(true);
                }
                DataSet changesDataSet = dataSet.GetChanges(DataRowState.Modified);

                int result = UpdateDataSet(dataSet, tableName, strSql);
                dataSet.AcceptChanges();

                if (result > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                LoggerManager.GetILog("MethodName:SaveDataToTable" + ex.StackTrace);
                return(false);
            }
        }
示例#2
0
 public DataTable FillDataTable(
     string tableName,
     string[] dbParams,
     object[] dbValues)
 {
     using (DbConnection _conn = CreateConnection())
     {
         try
         {
             DataTable dt = FillDataSet(
                 tableName,
                 dbParams,
                 dbValues).Tables[0];
             return(dt);
         }
         catch (Exception ex)
         {
             LoggerManager.GetILog("GetDataTable:SqlServerConfigInfo-" + ex.StackTrace);
             return(null);
         }
         finally
         {
             DisposeConnection(_conn);
         }
     }
 }
示例#3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public MySqlConfigInfo()
 {
     try
     {
         DbCommon.GetDbConfig(ref m_providerName, ref m_connString, this);
     }
     catch (CustomDataException ex)
     {
         LoggerManager.GetILog("Constructor:SqlServerConfigInfo-" + ex.StackTrace);
     }
 }
示例#4
0
        private void txtPinyin_TextChanged(object sender, System.EventArgs e)
        {
            try
            {
                if (this.txtPinyin.Text.Equals(""))
                {
                    return;
                }
                //dish.functions.CommValidate cv = new dish.functions.CommValidate();
                //string sql = "";
                string currentSearchType = "";

                DataTable dt = null;
                if (!Information.IsNumeric(this.txtPinyin.Text))
                {
                    if (!this.txtPinyin.Text.Equals(""))
                    {
                        //dt = new MenuManage().GetMenuInfoBySearchCondition(this.txtPinyin.Text);
                    }
                }
                else
                {
                    currentSearchType = "pinyin";
                    //dt = new MenuManage().GetMenuInfoBySearchCondition(this.txtPinyin.Text, true);
                }

                if (dt != null)
                {
                    this.BindDishCard(dt);
                }

                if (!this.dishCards[0].DishName.Equals("") && this.dishCards[1].DishName.Equals(""))
                {
                    this.DishCards_Click(this.dishCards[0].lblDishName, null);
                    if (this.frmPinyinAndCode == null)
                    {
                        this.frmPinyinAndCode = new frmPinyinAndCode();
                    }
                    this.frmPinyinAndCode.txtControl.Text = "";
                    this.txtPinyin.Text = string.Empty;
                    this.txtPinyin.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox2.Show(ex.ToString());

                LoggerManager.GetILog().Error(ex.StackTrace);
            }
        }
示例#5
0
        public SqlServerConfigInfo()
        {
            try
            {
                //System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetEntryAssembly().Location);
                //    m_providerName = config.AppSettings.Settings["DataProvider"].Value;
                //    m_connString = config.AppSettings.Settings["ConnectionString"].Value;

                DbCommon.GetDbConfig(ref m_providerName, ref m_connString, this);
            }
            catch (CustomDataException ex)
            {
                LoggerManager.GetILog("Constructor:SqlServerConfigInfo-" + ex.StackTrace);
            }
        }
示例#6
0
 //do not need focus on string para method
 private DataSet FillDataSet(string tbName, string[] dbParams, object[] dbValues)
 {
     using (DbConnection _conn = CreateConnection())
     {
         try
         {
             return(FillDataset(_conn, tbName, dbParams, dbValues));
         }
         catch (Exception ex)
         {
             LoggerManager.GetILog("MethodName:GetDataSet-" + ex.StackTrace);
             return(null);
         }
         finally
         {
             DisposeDBConnection(_conn);
         }
     }
 }
示例#7
0
 public void ExecuteNonQuery(
     string[] dbParams,
     object[] dbValues,
     string tbName,
     bool containsIdentityColumn = false
     )
 {
     using (DbConnection _conn = CreateConnection())
     {
         try
         {
             ExecuteNonQuery(tbName, dbParams, dbValues, containsIdentityColumn);
         }
         catch (Exception ex)
         {
             LoggerManager.GetILog("MethodName:[db]-ExecuteNonQuery-" + ex.StackTrace);
         }
         finally
         {
             DisposeConnection(_conn);
         }
     }
 }