protected bool InitInsertDDLInventaris()
    {
        SqlConnection conn  = Common.getConnection();
        string        query = "";
        bool          val   = false;
        SqlCommand    cmd   = new SqlCommand();

        cmd.Connection  = conn;
        cmd.CommandType = System.Data.CommandType.Text;

        if (HiddenType.Equals("barang"))
        {
            query = "select id, nama_inventaris, harga from m_inventaris where id not in(select id_inventaris from "
                    + " t_pengajuan_inventaris_detail where id_pengajuan = " + HiddenIDPengajuan.Value + ") order by id asc";
        }
        else if (HiddenType.Equals("service"))
        {
            query = "select id, nama_inventaris, harga from m_inventaris where id not in(select id_inventaris from "
                    + " t_service_inventaris_detail where id_pengajuan = " + HiddenIDPengajuan.Value + ") order by id asc";
        }
        else
        {
            query = "select id, nama_inventaris from m_inventaris";
        }

        cmd.CommandText = query;

        conn.Open();
        SqlDataReader reader = cmd.ExecuteReader();

        if (reader.HasRows)
        {
            val = true;
            DDLInventaris.DataSource     = reader;
            DDLInventaris.DataValueField = "id";
            DDLInventaris.DataTextField  = "nama_inventaris";
            DDLInventaris.DataBind();
            //   DDLHarga.DataBind();
        }


        conn.Close();


        return(val);
    }
Пример #2
0
 static void Main(string[] args)
 {
     var hidden = new HiddenType();
 }