C#Ref
C#Ref
C#Ref
OleDb;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace newdepot
{
public partial class frmLogin : Form
{
String constr = null;
public frmLogin()
{
InitializeComponent();
}
String sql = "select * from admininfo where password= '" + txtadmpass.Text + "'";
try
{
con.Open();
Reader = cmd.ExecuteReader();
if (Reader.Read() == true)
{
Form2 ob=new Form2();
ob.show();
}
else
MessageBox.Show("Invalid User");
}
catch (Exception ee)
{
MessageBox.Show("Error.." +ee.Message);
}
//Insert Code
if (comboBox1.Text.Equals("") || textBox2.Text.Equals("") )
{
MessageBox.Show("You are missing information");
textBox2.Focus();
return;
}
String sql = "insert into tnlname values (" + textBox2.Text + ",'" comboBox3.Text
+ "')";
int i;
try
{
con.Open();
i = cmd.ExecuteNonQuery();
MessageBox.Show("inserted");
}
catch (Exception ee) {
MessageBox.Show(ee.Message.ToString ());
}
~~~~~~~~~~~~~~~~~~
//Search Code
~~~~~~~~~~~~~~~~~~
String sql = "select * from tbl where pname='" + txtpname.Text.ToUpper () + "'";
try
{
con.Open();
Reader = cmd.ExecuteReader();
Reader.Read();
txtdeptname.Text = Reader.GetString(1);
txtmgrname.Text = Reader.GetString(2);
Button5.Enabled = true; //update
Button6.Enabled = true; //delete
}
catch (Exception ee)
{
MessageBox.Show("Error.." + ee.Message);
##################
private void AutoGen()
{
String sql = "select Br_Code from branch order by Br_Code desc";
OleDbConnection con = new OleDbConnection();
con.ConnectionString = constr;
OleDbCommand cmd = new OleDbCommand(sql, con);
OleDbDataReader Reader = null;
try
{
con.Open();
Reader = cmd.ExecuteReader();
if (Reader.Read())
{
int temp = Reader.GetInt32(0) + 1;
txtbrcode.Text = temp.ToString();
}
else
txtbrcode.Text = "1";
}
catch (Exception ee)
{
MessageBox.Show("Error.." + ee.Message);