protected bool InitDDLInventaris() { SqlConnection conn = Common.getConnection(); string query = ""; bool val = false; SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = System.Data.CommandType.Text; query = "select id_inventaris, nama_inventaris from m_inventaris order by id_inventaris asc"; cmd.CommandText = query; conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { val = true; DDLInventaris.DataSource = reader; DDLInventaris.DataValueField = "id_inventaris"; DDLInventaris.DataTextField = "nama_inventaris"; DDLInventaris.DataBind(); // DDLHarga.DataBind(); } conn.Close(); SqlConnection conn2 = Common.getConnection(); string query2 = ""; SqlCommand cmd2 = new SqlCommand(); cmd2.Connection = conn2; cmd2.CommandType = System.Data.CommandType.Text; query2 = "select id_inventaris, harga from m_inventaris order by id_inventaris asc"; cmd2.CommandText = query2; conn2.Open(); SqlDataReader reader2 = cmd2.ExecuteReader(); if (reader2.HasRows) { val = true; DDLHarga.DataSource = reader2; DDLHarga.DataValueField = "harga"; DDLHarga.DataTextField = "harga"; DDLHarga.DataBind(); } conn2.Close(); return(val); }
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; query = "select id_inventaris, nama_inventaris, harga from m_inventaris where id_inventaris not in(select id_inventaris from " + " t_pengajuan_inventaris_detail where id_pengajuan_inventaris = '" + HiddenIDPengajuan.Value + "') order by id_inventaris asc"; System.Diagnostics.Debug.WriteLine("Query " + query); cmd.CommandText = query; conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { val = true; DDLInventaris.DataSource = reader; DDLInventaris.DataValueField = "id_inventaris"; DDLInventaris.DataTextField = "nama_inventaris"; DDLInventaris.DataBind(); // DDLHarga.DataBind(); } conn.Close(); SqlConnection conn2 = Common.getConnection(); string query2 = ""; bool val2 = false; SqlCommand cmd2 = new SqlCommand(); cmd2.Connection = conn2; cmd2.CommandType = System.Data.CommandType.Text; query2 = "select id_inventaris, harga from m_inventaris where id_inventaris not in(select id_inventaris from " + " t_pengajuan_inventaris_detail where id_pengajuan_inventaris = '" + HiddenIDPengajuan.Value + "') order by id_inventaris asc"; cmd2.CommandText = query2; conn2.Open(); SqlDataReader reader2 = cmd2.ExecuteReader(); if (reader2.HasRows) { val = true; DDLHarga.DataSource = reader2; DDLHarga.DataValueField = "harga"; DDLHarga.DataTextField = "harga"; DDLHarga.DataBind(); } conn2.Close(); return(val); }