Beispiel #1
0
        public List <cUkm> GetUKM(string Name)
        {
            List <cUkm> ukm = new List <cUkm>();

            {
                con.Open();
                SqlCommand cmd = new SqlCommand("select * from UKM where Ukmname like '%'+@Name+'%'", con);
                cmd.Parameters.AddWithValue("@Name", Name);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        cUkm customerInfo = new cUkm();
                        customerInfo.Id      = dt.Rows[i]["id"].ToString();
                        customerInfo.Ukmname = dt.Rows[i]["Ukmname"].ToString();
                        customerInfo.Desc    = dt.Rows[i]["Description"].ToString();
                        customerInfo.Idcoach = dt.Rows[i]["id_coach"].ToString();
                        ukm.Add(customerInfo);
                    }
                }
                con.Close();
            }

            return(ukm);
        }
Beispiel #2
0
        public int doInsertUKM(cUkm acc)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("insert into UKM(Ukmname, Description, id_coach) values(@ukm, @desc, @idcoach)", con);

            cmd.Parameters.AddWithValue("@ukm", acc.Ukmname);
            cmd.Parameters.AddWithValue("@desc", acc.Desc);
            cmd.Parameters.AddWithValue("@idcoach", acc.Idcoach);

            int result = cmd.ExecuteNonQuery();

            if (result == 1)
            {
                con.Close();
                return(1);
            }
            else
            {
                con.Close();
                return(0);
            }
        }
Beispiel #3
0
        public int doUpdateUKM(cUkm acc)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("update UKM set Ukmname=@name, Description=@desc, id_coach=@coach where id=@id", con);

            cmd.Parameters.AddWithValue("@name", acc.Ukmname);
            cmd.Parameters.AddWithValue("@desc", acc.Desc);
            cmd.Parameters.AddWithValue("@coach", acc.Idcoach);
            cmd.Parameters.AddWithValue("@id", acc.Id);

            int result = cmd.ExecuteNonQuery();

            if (result == 1)
            {
                con.Close();
                return(1);
            }
            else
            {
                con.Close();
                return(0);
            }
        }