Exemplo n.º 1
0
 public static string login(Manager mag)//判断经理用户名密码是否一致
 {
     string str = "";
     SqlDataReader sqlrd;
     DataBase db = new DataBase();
     string sql = "select tKey from tb_Manager where Name='" + mag.Name + "'";
     sqlrd = db.GetDataReader(sql);
     while (sqlrd.Read())
     {
         str = (string)(sqlrd["tKey"]);
     }
     return str;
 }
Exemplo n.º 2
0
 public static string  login(Stuff stf)//判断员工用户名密码是否一致
 {
     string str="";
     SqlDataReader sqlrd;
     DataBase  db = new DataBase();
     string sql = "select tKey from tb_Stuff where Name='" + stf.Name + "'";
     sqlrd=db.GetDataReader(sql);
     while(sqlrd.Read ())
     {
         str = (string)(sqlrd["tKey"]); 
     }
     return str;
 }
Exemplo n.º 3
0
        public static DataTable GetData(DataBase dataBaseType, CommandType commandType, string query, SqlParameter[] parameters = null)
        {
            SqlConnection conn = new SqlConnection(GetConnectionStaring(dataBaseType));
            SqlCommand cmd = conn.CreateCommand();
            SqlDataReader reader = null;

            try
            {
                cmd.CommandType = commandType;
                cmd.CommandText = query;
                if (parameters != null)
                    parameters.ToList().ForEach(s =>
                    {
                        cmd.Parameters.Add(s);
                    });

                DataTable dt = new DataTable();

                conn.Open();
                reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                dt.Load(reader);

                return dt;
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
                if (cmd != null)
                {
                    if (cmd.Parameters != null)
                    {
                        cmd.Parameters.Clear();
                    }
                    cmd.Dispose();
                }
                if (conn != null && conn.State == ConnectionState.Open)
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }
Exemplo n.º 4
0
 public static int StoreData_ExecuteNonQuery(DataBase dataBaseType, CommandType commandType, string query, SqlParameter[] parameters = null)
 {
     return(StoreData_ExecuteNonQuery(dataBaseType, commandType, query, parameters, null));
 }
Exemplo n.º 5
0
 public static void Save()
 {
     DataBase db = new DataBase();
     string sql = "insert ";
 }
Exemplo n.º 6
0
 public static DataTable GetAllUser()
 {
     DataBase db = new DataBase();
     return db.GetDataTable("Select * from Customer");
 }
Exemplo n.º 7
0
        public DataTable getRegion(String strWhere)
        {
            String sql = "select * from DictRegion where 1=1 " + strWhere;

            return(DataBase.Base_dt(sql));
        }
Exemplo n.º 8
0
        public static int StoreData_ExecuteNonQuery(DataBase dataBaseType, CommandType commandType, string query, SqlParameter[] parameters = null, List<TVParameter> TVParameters = null)
        {
            SqlConnection conn = new SqlConnection(GetConnectionStaring(dataBaseType));
            SqlCommand cmd = conn.CreateCommand();

            try
            {
                cmd.CommandType = commandType;
                cmd.CommandText = query;
                if (parameters != null)
                    parameters.ToList().ForEach(s =>
                    {
                        cmd.Parameters.Add(s);
                    });
                if (TVParameters != null)
                    TVParameters.ToList().ForEach(s =>
                    {
                        SqlParameter tvpParam = cmd.Parameters.AddWithValue(s.ParameterName, s.ParameterValue);
                        tvpParam.SqlDbType = s.SqlDbType;
                        tvpParam.TypeName = s.ParameterTypeName;
                    });
                conn.Open();
                return cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (cmd != null)
                {
                    if (cmd.Parameters != null)
                    {
                        cmd.Parameters.Clear();
                    }
                    cmd.Dispose();
                }
                if (conn != null && conn.State == ConnectionState.Open)
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }
Exemplo n.º 9
0
 public static int StoreData_ExecuteNonQuery(DataBase dataBaseType, CommandType commandType, string query, SqlParameter[] parameters = null)
 {
     return StoreData_ExecuteNonQuery(dataBaseType, commandType, query, parameters, null);
 }
Exemplo n.º 10
0
 private static string GetConnectionStaring(DataBase dataBaseType)
 {
     if (_con == null)
     {
         _con = ConfigurationManager.ConnectionStrings[dataBaseType.ToString()].ConnectionString;
     }
     return _con;
 }
Exemplo n.º 11
0
 public static void StoreData_ExecuteNonQuery_ParamList(DataBase dataBaseType, CommandType commandType, string query, List<SqlParameter[]> parametersList = null)
 {
     if (parametersList == null || parametersList.Count == 0)
     {
         StoreData_ExecuteNonQuery(dataBaseType, commandType, query, null);
         return;
     }
     else
     {
         parametersList.ForEach(pL =>
         {
             StoreData_ExecuteNonQuery(dataBaseType, commandType, query, pL);
         });
     }
 }
Exemplo n.º 12
0
        public DataTable getProductsById(String id)
        {
            String sql = "select * from Products where Id='" + id + "'";

            return(DataBase.Base_dt(sql));
        }
Exemplo n.º 13
0
        public DataTable getProducts()
        {
            String sql = "select * from Products where state=1";

            return(DataBase.Base_dt(sql));
        }
Exemplo n.º 14
0
        public bool Delete(String id)
        {
            String sql = "delete [dbo].[OrdersDetail] where Id='" + id + "'";

            return(DataBase.Base_cmd(sql));
        }