private void SOCreation_Load(object sender, EventArgs e)
 {
     mc = new MyConnection();
     mc.conn.Open();
     cmd = new OleDbCommand("select CID from Customer where CStatus='Active';", mc.conn);
     dr  = cmd.ExecuteReader();
     while (dr.Read())
     {
         comboBox1.Items.Add(dr["CID"]);
     }
     cmd = new OleDbCommand("select PModel from Products;", mc.conn);
     dr  = cmd.ExecuteReader();
     while (dr.Read())
     {
         comboBox2.Items.Add(dr["PModel"]);
     }
     mc.conn.Close();
 }
Beispiel #2
0
 private void Customer_Load(object sender, EventArgs e)
 {
     mc = new MyConnection();
     mc.conn.Open();
     if (selection == "add")
     {
         this.Text          = "Add Customer";
         textBox11.Text     = "Inactive";
         textBox11.ReadOnly = true;
         comboBox2.Visible  = false;
         mc = new MyConnection();
         mc.conn.Open();
         cmd = new OleDbCommand("select GrpName from CusGroup;", mc.conn);
         dr  = cmd.ExecuteReader();
         while (dr.Read())
         {
             comboBox1.Items.Add(dr["GrpName"]);
         }
     }
     else if (selection == "approve")
     {
         this.Text = "Approve Customer";
         cmd       = new OleDbCommand("select CID from Customer where CStatus='Inactive';", mc.conn);
         dr        = cmd.ExecuteReader();
         while (dr.Read())
         {
             comboBox2.Items.Add(dr["CID"]);
         }
         mc.conn.Close();
         button2.Text       = "Approve";
         textBox1.Visible   = false;
         comboBox2.Visible  = true;
         comboBox1.Enabled  = false;
         textBox2.ReadOnly  = true;
         textBox3.ReadOnly  = true;
         textBox4.ReadOnly  = true;
         textBox5.ReadOnly  = true;
         textBox6.ReadOnly  = true;
         textBox7.ReadOnly  = true;
         textBox8.ReadOnly  = true;
         textBox9.ReadOnly  = true;
         textBox10.ReadOnly = true;
         textBox11.ReadOnly = true;
     }
     else if (selection == "search")
     {
         this.Text          = "Search Customer";
         button1.Visible    = false;
         button2.Visible    = false;
         button3.Visible    = false;
         textBox1.Visible   = false;
         comboBox2.Visible  = true;
         comboBox1.Enabled  = false;
         textBox2.ReadOnly  = true;
         textBox3.ReadOnly  = true;
         textBox4.ReadOnly  = true;
         textBox5.ReadOnly  = true;
         textBox6.ReadOnly  = true;
         textBox7.ReadOnly  = true;
         textBox8.ReadOnly  = true;
         textBox9.ReadOnly  = true;
         textBox10.ReadOnly = true;
         textBox11.ReadOnly = true;
         cmd = new OleDbCommand("select CID from Customer;", mc.conn);
         dr  = cmd.ExecuteReader();
         while (dr.Read())
         {
             comboBox2.Items.Add(dr["CID"]);
         }
     }
     else if (selection == "update")
     {
         this.Text    = "Update Customer";
         button2.Text = "Update";
         cmd          = new OleDbCommand("select CID from Customer;", mc.conn);
         dr           = cmd.ExecuteReader();
         while (dr.Read())
         {
             comboBox2.Items.Add(dr["CID"]);
         }
         textBox1.Visible   = false;
         comboBox1.Enabled  = false;
         textBox2.ReadOnly  = false;
         textBox3.ReadOnly  = false;
         textBox4.ReadOnly  = false;
         textBox5.ReadOnly  = false;
         textBox6.ReadOnly  = false;
         textBox7.ReadOnly  = false;
         textBox8.ReadOnly  = false;
         textBox9.ReadOnly  = false;
         textBox10.ReadOnly = false;
         textBox11.ReadOnly = true;
     }
     mc.conn.Close();
 }