예제 #1
0
        public static int InsertOptions(MProfileOptions ent)
        {
            using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString()))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("sp_ProfileOptions_Ins", con);
                    cmd.CommandTimeout = 0;
                    cmd.Parameters.Add("@IProfileId", SqlDbType.VarChar).Value = ent.ProfileId;
                    cmd.Parameters.Add("@IOptionId", SqlDbType.VarChar).Value  = ent.OptionId;

                    cmd.CommandType = CommandType.StoredProcedure;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();

                    return(0);
                }

                catch (Exception ex)
                {
                    return(2);
                }
            }
        }
예제 #2
0
        public static List <MProfileOptions> SelOptions(MProfile ent, ref int Val)
        {
            List <MProfileOptions> lisQuery = new List <MProfileOptions>();

            using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString()))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("sp_ProfileOptions_Sel", con);
                    cmd.Parameters.Add("@IProfileId", SqlDbType.VarChar).Value = ent.ProfileId;
                    cmd.CommandTimeout = 0;
                    cmd.CommandType    = CommandType.StoredProcedure;
                    con.Open();

                    Val = 1;

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            MProfileOptions entRow = new MProfileOptions();
                            entRow.ProfileId = Convert.ToInt32(reader["ProfileId"]);
                            entRow.OptionId  = Convert.ToInt32(reader["OptionId"]);
                            lisQuery.Add(entRow);

                            Val = 0;
                        }
                    }
                    con.Close();
                }

                catch (Exception ex)
                {
                    Val = 2;
                }
            }

            return(lisQuery);
        }