OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=E:\\Rice\\Rice.mdb");
public Purchase()
{
InitializeComponent();
}
private void Idgen()
{
int id = 0;
String str1 = "Select MAX(PurNos) from T_PurMasTable";
OleDbCommand cmd = new OleDbCommand(str1, con);
con.Open();
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (dr.IsDBNull(0) == false)
{
id = dr.GetInt32(0) + 1;
}
else
{
id = 1;
}
}
cbxpurno.Text = id.ToString();
dr.Close();
con.Close();
}
private void Idshow()
{
cbxpurno.Items.Clear();
cbxpurno.Text = "Select";
String str = "Select * from T_PurMasTable";
OleDbCommand cmd = new OleDbCommand(str, con);
con.Open();
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (dr.IsDBNull(0) == false)
{
cbxpurno.Items.Add(dr.GetValue(0).ToString());
}
}
dr.Close();
con.Close();
}
private void TextClear()
{
cbxRBname.Text = "";
cbxrtype.Text = "";
txtnopct.Text = "";
txttotkg.Text = "";
txtprice.Text = "";
txttotamt.Text = "";
}
private void RsTot()
{
try
{
double NetAmt = 0;
int c = dataGridView1.Rows.Count - 1;
for (int i = 0; i < c; i++)
{
string NAmt = dataGridView1[5, i].Value.ToString();
double Amt = Convert.ToDouble(NAmt );
NetAmt += Amt ;
}
txtnetamt .Text = Convert.ToString(NetAmt );
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void AddtoGrid()
{
if (cbxRBname.Text != "Select" && txtnopct.Text != "" && txttotkg.Text != "" && txtprice.Text != "")
{
string sn = dataGridView1.Rows.Count.ToString();
string brand = cbxRBname.Text;
string npcts = txtnopct.Text;
string tot = txttotkg.Text;
string pri = txtprice.Text;
string totamt = txttotamt.Text;
string[] add = new string[] { sn, brand, npcts, tot, pri, totamt };
dataGridView1.Rows.Add(add);
}
}
private void Purchase_Load(object sender, EventArgs e)
{
stock();
purchase();
cbxdtppurdate.Text = DateTime.Now.ToShortDateString();
cbxRBname.Text = "Select";
cbxpurno.Text = "Select";
//txtinvono.Text = "Select";
cbxsupname.Text = "Select";
//rice();
String str3 = "Select * from Supinfo";
OleDbCommand cmd = new OleDbCommand(str3, con);
con.Open();
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (dr.IsDBNull(0) == false)
{
cbxsupname.Items.Add(dr.GetValue(1).ToString());
}
}
dr.Close();
con.Close();
}
private void stock()
{
String str4 = "Select * from StockEntry";
OleDbCommand cmd1 = new OleDbCommand(str4, con);
con.Open();
OleDbDataReader dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
if (dr1.IsDBNull(0) == false)
{
cbxRBname.Items.Add(dr1.GetValue(1).ToString());
cbxrtype.Items.Add(dr1.GetValue(2).ToString());
}
if (cbxRBname.Items.Count == 1)
{
cbxRBname.DropDownStyle = ComboBoxStyle.Simple;
}
else
cbxRBname.DropDownStyle = ComboBoxStyle.DropDown;
}
dr1.Close();
con.Close();
}
No comments:
Post a Comment