01-05-17, 02:42 AM
جربه الان
PHP كود :
using Gecko;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
namespace Al_Emlaq_TV
{
public partial class Form1 : Form
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|db.accdb;Jet OLEDB:Database Password=01207600205");
OleDbDataAdapter da = null;
DataSet ds= null;
string sqlstr = null;
private System.Net.WebClient wc = new System.Net.WebClient();
private void wc_download_combleted()
{
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//wc.DownloadFileAsync(new System.Uri("http://dl.dropboxusercontent.com/s/o5vn683zoqsfqor/db.accdb"), Application.StartupPath + "\\db.accdb");
InitializeComponent();
LoadCategory();
}
public void LoadCategory()
{
try
{
sqlstr = "Select Id,VideoCategory From tblCategory";
da = new OleDbDataAdapter(sqlstr, con);
ds = new DataSet();
ds.Clear();
da.Fill(ds, "tblCategory");
ComboBox1.Items.Clear();
ComboBox1.DataSource = ds.Tables["tblCategory"];
ComboBox1.ValueMember = "id";
ComboBox1.DisplayMember = "VideoCategory";
}
catch (Exception ex)
{
//if (ex.Message.ToString.ToLower.Contains("cannot open database it may not be a database that your application recognizes"))
// {
//Interaction.MsgBox("حدثت مشكلة فى البرنامج و جارى تحميل ملف حل المشكلة الرجاء تيطيبة بعد اكتمال التحميل و عدم غلق البرنامج الا مع اكتمال التحميل", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "خطأ");
//My.Computer.Network.DownloadFile("https://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine.exe", Application.StartupPath + "\\AccessDatabaseEngine.exe");
////كدة هيحمل الملف اللى هيصلح الرسالة التانية جنب البرنامج
//IO.File.Open(Application.StartupPath + "\\AccessDatabaseEngine.exe", IO.FileMode.Open);
// }
//else if (ex.Message.ToString.ToLower.Contains("the microsoft.ace.oledb.12.0 provider is not registered on the local machine"))
// {
//Interaction.MsgBox("حدثت مشكلة فى البرنامج و جارى تحميل ملف حل المشكلة الرجاء تيطيبة بعد اكتمال التحميل و عدم غلق البرنامج الا مع اكتمال التحميل", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "خطأ");
//My.Computer.Network.DownloadFile("https://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine.exe", Application.StartupPath + "\\AccessDatabaseEngine.exe");
//IO.File.Open(Application.StartupPath + "\\AccessDatabaseEngine.exe", IO.FileMode.Open);
}
}
public void LoadVideoName(int Value)
{
try
{
sqlstr = "Select Id,VideoName From tblVideo Where CategoryId = @CategoryId";
da = new OleDbDataAdapter(sqlstr, con);
da.SelectCommand.Parameters.Add(new OleDbParameter("@CategoryId", Value));
if (ds.Tables.Contains("tblVideo"))
{
ds.Tables["tblVideo"].Clear();
}
da.Fill(ds, "tblVideo");
ComboBox2.DataSource = ds.Tables["tblVideo"];
ComboBox2.ValueMember = "id";
ComboBox2.DisplayMember = "VideoName";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public void LoadSubVideo(int Value)
{
try
{
sqlstr = "Select Id,SubVideo,LinkVideo From tblSubVideo Where VideoId = @VideoId";
da = new OleDbDataAdapter(sqlstr, con);
da.SelectCommand.Parameters.Add(new OleDbParameter("@VideoId", Value));
if (ds.Tables.Contains("tblSubVideo"))
{
ds.Tables["tblSubVideo"].Clear();
}
da.Fill(ds, "tblSubVideo");
ListBox1.DataSource = ds.Tables["tblSubVideo"];
ListBox1.ValueMember = "LinkVideo";
ListBox1.DisplayMember = "SubVideo";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
LoadVideoName(int.Parse(ComboBox1.SelectedValue.ToString()));
if (ComboBox1.Items.Count > 0)
{
LoadSubVideo(int.Parse(ComboBox2.SelectedValue.ToString()));
if (ListBox1.Items.Count <= 0)
{
}
else
{
}
}
else
{
ComboBox2.DataSource = null;
ListBox1.DataSource = null;
}
}
catch (Exception ex)
{
}
}
private void ComboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
if (ComboBox2.Items.Count > 0)
{
LoadSubVideo(int.Parse(ComboBox2.SelectedValue.ToString()));
if (ListBox1.Items.Count > 0)
{
}
else
{
}
}
else
{
ListBox1.DataSource = null;
}
}
catch (Exception ex)
{
}
}
private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void ListBox1_MouseClick(object sender, MouseEventArgs e)
{
if (ListBox1.SelectedValue != null)
{
webBrowser1.Navigate(new Uri(ListBox1.SelectedValue.ToString()));
}
}
}
}
اللهم لك الحمد كما ينبغي لجلال وجهك و عظيم سلطانك
في حل و ترحال


