Login Master
public partial class Login___Master : Form
{
Dbclass db = new Dbclass();
string common;
public Login___Master()
{
InitializeComponent();
}
private void btnlogin_in_Click(object sender, EventArgs e)
{
DataTable dt2 = new DataTable();
MDI objmdi = new MDI();
if (cmblogin_type.Text == "")
{
MessageBox.Show("Error 9001303991 : FillUp the Login Type", "Blank..........", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
return;
}
if (btnlogin_in.Text == "Login")
{
//try
{
string str = "login,'" + cmblogin_type.Text + "','" + cmbuser_name.Text + "','" + txtpassword.Text + "'";
dt2=db.FindFun(str);
if (dt2.Rows.Count > 0)
{
objmdi.Show();
}
else
{
MessageBox.Show("invalid user", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
}
}
}
}
private void btnlogin_out_Click(object sender, EventArgs e)
{
MDI md = new MDI();
md.Close();
}
private void Login___Master_Load(object sender, EventArgs e)
{
Dbclass obj = new Dbclass();
// grpfind.Visible = true;
string str = "Select * from user_master";
obj.Fillcombo(cmblogin_type , "user_type", "unq_id", str);
obj.Fillcombo(cmbuser_name , "user_name", "unq_id", str);
}
}
}
----------------------------------------------------------------------
Message Show
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
if (!bClosing)
{
bClosing = true;
if (MessageBox.Show("Are sure You want to exit?", "Exit?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
{
e.Cancel = true;
}
else
{
e.Cancel = false;
}
}
else
{
bClosing = false;
}
}
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
private void searchAllToolStripMenuItem_Click(object sender, EventArgs e)
{
Search srch = new Search();
srch.Show();
}
private void searchReportToolStripMenuItem_Click(object sender, EventArgs e)
{
SearchStatus srchst = new SearchStatus();
srchst.Show();
}
}
}
------------------------------------------------------------------------------
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;
using System.Data.SqlClient;
namespace Bar_nd_Hotel
{
public partial class crtVeg : Form
{
public crtVeg()
{
InitializeComponent();
}
AutoCompleteStringCollection codeCollection = new AutoCompleteStringCollection();
List<string> arraylistitm = new List<string>();
List<string> arraylistqty = new List<string>();
private void crtVeg_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'bar_dbDataSet3.category' table. You can move, or remove it, as needed.
this.categoryTableAdapter.Fill(this.bar_dbDataSet3.category);
// TODO: This line of code loads data into the 'bar_dbDataSet1.veg_category' table. You can move, or remove it, as needed.
//this.veg_categoryTableAdapter.Fill(this.bar_dbDataSet1.veg_category);
string constring = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con = new SqlConnection(constring);
string cmdstring = "select crt_categ from category where main_cat = 'Veg. Items'";
SqlCommand cmd = new SqlCommand(cmdstring, con);
con.Open();
SqlDataReader dr;
dr = cmd.ExecuteReader();
while (dr.Read())
{
vegcatcmb.Items.Add(dr["crt_categ"].ToString());
}
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "select distinct itm_code from crt_veg order by itm_code";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
con1.Open();
SqlDataReader dr1;
dr1 = cmd1.ExecuteReader();
if (dr1.HasRows == true)
{
while (dr1.Read())
{
codeCollection.Add(dr1["itm_code"].ToString());
}
}
dr1.Close();
vegcode.AutoCompleteMode = AutoCompleteMode.Suggest;
vegcode.AutoCompleteSource = AutoCompleteSource.CustomSource;
vegcode.AutoCompleteCustomSource = codeCollection;
}
private void button1_Click(object sender, EventArgs e)
{
arraylistitm.Add(itm1.Text);
arraylistitm.Add(itm2.Text);
arraylistitm.Add(itm3.Text);
arraylistitm.Add(itm4.Text);
arraylistitm.Add(itm5.Text);
arraylistitm.Add(itm6.Text);
arraylistitm.Add(itm7.Text);
arraylistitm.Add(itm8.Text);
arraylistitm.Add(itm9.Text);
arraylistitm.Add(itm10.Text);
arraylistqty.Add(qty1.Text);
arraylistqty.Add(qty2.Text);
arraylistqty.Add(qty3.Text);
arraylistqty.Add(qty4.Text);
arraylistqty.Add(qty5.Text);
arraylistqty.Add(qty6.Text);
arraylistqty.Add(qty7.Text);
arraylistqty.Add(qty8.Text);
arraylistqty.Add(qty9.Text);
arraylistqty.Add(qty10.Text);
int n = 0;
for (int j = 0; j < 10; j++)
{
if (arraylistitm[j].Length > 1)
{
n++;
}
}
for (int i = 0; i < n; i++)
{
if (i == 0)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm1.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm1.Text + "', '" +Convert.ToDateTime( DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name,date) values( '" + itm1.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "' ) ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 1)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm2.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm2.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "' ) ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name,date) values( '" + itm2.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 2)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm3.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm3.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm3.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 3)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm4.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm4.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm4.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 4)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm5.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm5.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm5.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 5)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm6.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm6.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm6.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 6)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm7.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm7.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm7.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 7)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm8.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm8.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm8.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 8)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm9.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm9.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm9.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 9)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm10.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm10.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm10.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
}
string constring = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con = new SqlConnection(constring);
string cmdstring = "insert into crt_veg (itm_categ,itm_name,itm_code,itm_amt,itm1,qty1,itm2,qty2,itm3,qty3,itm4,qty4,itm5,qty5,itm6,qty6,itm7,qty7,itm8,qty8,itm9,qty9,itm10,qty10) values( '" + vegcatcmb.Text + "','" + vegname.Text + "', '" + Convert.ToInt32(vegcode.Text) + "', '" + vegamt.Text + "', '" + itm1.Text + "', '" + qty1.Text + "','" + itm2.Text + "', '" + qty2.Text + "','" + itm3.Text + "', '" + qty3.Text + "','" + itm4.Text + "', '" + qty4.Text + "','" + itm5.Text + "', '" + qty5.Text + "','" + itm6.Text + "', '" + qty6.Text + "','" + itm7.Text + "', '" + qty7.Text + "','" + itm8.Text + "', '" + qty8.Text + "','" + itm9.Text + "', '" + qty9.Text + "','" + itm10.Text + "', '" + qty10.Text + "') ";
SqlCommand cmd = new SqlCommand(cmdstring, con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
//for (int i = 0; i < n; i++)
//{
// string cmdstring1 = "insert into VegCntItems (itm_code,itm_name,itm_cnt_name,itm_cnt_qty,itm_amt) values( '" + vegcode.Text + "','" + vegname.Text + "' , '" + arraylistitm[i].ToString() + "', '" + arraylistqty[i].ToString() + "', '" + vegamt.Text + "') ";
// SqlCommand cmd1 = new SqlCommand(cmdstring1, con);
// con.Open();
// cmd1.ExecuteNonQuery();
// con.Close();
//}
MessageBox.Show("New Veg Items has Been Added Successfully ");
con.Close();
//vegcatcmb.Text = "";
//vegname.Text = "";
//vegcode.Text = "";
//vegamt.Text = "";
con.Close();
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
string constring = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con = new SqlConnection(constring);
string cmdstring = "update crt_veg set itm_name = '" + vegname.Text + "',itm_amt = '" + vegamt.Text + "', itm1 = '" + itm1.Text + "',qty1 = '" + qty1.Text + "', itm2 = '" + itm2.Text + "',qty2 = '" + qty2.Text + "', itm3 = '" + itm3.Text + "',qty3 = '" + qty3.Text + "', itm4 = '" + itm4.Text + "',qty4 = '" + qty4.Text + "', itm5 = '" + itm5.Text + "',qty5 = '" + qty5.Text + "', itm6 = '" + itm6.Text + "',qty6 = '" + qty6.Text + "', itm7 = '" + itm7.Text + "',qty7 = '" + qty7.Text + "', itm8 = '" + itm8.Text + "',qty8 = '" + qty8.Text + "', itm9 = '" + itm9.Text + "',qty9 = '" + qty9.Text + "' , itm10 = '" + itm10.Text + "',qty10 = '" + qty10.Text + "' where itm_categ = '" + vegcatcmb.Text + "' and itm_code = '" + vegcode.Text + "' ";
SqlCommand cmd = new SqlCommand(cmdstring, con);
con.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Item details has been Updated Successfully ");
con.Close();
//vegcatcmb.Text = "";
//vegname.Text = "";
//vegcode.Text = "";
//vegamt.Text = "";
con.Close();
this.Close();
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void qty6_TextChanged(object sender, EventArgs e)
{
}
private void vegcode_TextChanged(object sender, EventArgs e)
{
//int n = 0;
//string constring = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
//SqlConnection con = new SqlConnection(constring);
//string cmdstring = "select itm_code from VegCntItems where itm_code = '" + vegcode.Text + "'";
//SqlCommand cmd = new SqlCommand(cmdstring, con);
//con.Open();
//SqlDataReader dr;
//dr = cmd.ExecuteReader();
//while (dr.Read())
//{
// n++;
//}
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "select * from crt_veg where itm_code = '" + vegcode.Text + "'";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
con1.Open();
SqlDataReader dr1;
dr1 = cmd1.ExecuteReader();
if (dr1.Read())
{
vegname.Text = dr1["itm_name"].ToString();
vegamt.Text = dr1["itm_amt"].ToString();
vegcatcmb.Text = dr1["itm_categ"].ToString();
itm1.Text = dr1["itm1"].ToString();
qty1.Text = dr1["qty1"].ToString();
itm2.Text = dr1["itm2"].ToString();
qty2.Text = dr1["qty2"].ToString();
itm3.Text = dr1["itm3"].ToString();
qty3.Text = dr1["qty3"].ToString();
itm4.Text = dr1["itm4"].ToString();
qty4.Text = dr1["qty4"].ToString();
itm5.Text = dr1["itm5"].ToString();
qty5.Text = dr1["qty5"].ToString();
itm6.Text = dr1["itm6"].ToString();
qty6.Text = dr1["qty6"].ToString();
itm7.Text = dr1["itm7"].ToString();
qty7.Text = dr1["qty7"].ToString();
itm8.Text = dr1["itm8"].ToString();
qty8.Text = dr1["qty8"].ToString();
itm9.Text = dr1["itm9"].ToString();
qty9.Text = dr1["qty9"].ToString();
itm10.Text = dr1["itm10"].ToString();
qty10.Text = dr1["qty10"].ToString();
}
else
{
vegname.Text = "";
vegamt.Text = "";
itm1.Text = "";
qty1.Text = "";
itm2.Text = "";
qty2.Text = "";
itm3.Text = "";
qty3.Text = "";
itm4.Text = "";
qty4.Text = "";
itm5.Text = "";
qty5.Text = "";
itm6.Text = "";
qty6.Text = "";
itm7.Text = "";
qty7.Text = "";
itm8.Text = "";
qty8.Text = "";
itm9.Text = "";
qty9.Text = "";
itm10.Text = "";
qty10.Text = "";
}
}
private void vegcatcmb_SelectedIndexChanged(object sender, EventArgs e)
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "select itm_code from crt_veg where itm_categ = '" + vegcatcmb.Text + "' ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
con1.Open();
SqlDataReader dr1;
dr1 = cmd1.ExecuteReader();
if (dr1.HasRows == true)
{
while (dr1.Read())
{
codeCollection.Add(dr1["itm_code"].ToString());
}
}
else
{
codeCollection.Clear();
}
dr1.Close();
vegcode.AutoCompleteMode = AutoCompleteMode.Suggest;
vegcode.AutoCompleteSource = AutoCompleteSource.CustomSource;
vegcode.AutoCompleteCustomSource = codeCollection;
}
}
}
public partial class Login___Master : Form
{
Dbclass db = new Dbclass();
string common;
public Login___Master()
{
InitializeComponent();
}
private void btnlogin_in_Click(object sender, EventArgs e)
{
DataTable dt2 = new DataTable();
MDI objmdi = new MDI();
if (cmblogin_type.Text == "")
{
MessageBox.Show("Error 9001303991 : FillUp the Login Type", "Blank..........", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
return;
}
if (btnlogin_in.Text == "Login")
{
//try
{
string str = "login,'" + cmblogin_type.Text + "','" + cmbuser_name.Text + "','" + txtpassword.Text + "'";
dt2=db.FindFun(str);
if (dt2.Rows.Count > 0)
{
objmdi.Show();
}
else
{
MessageBox.Show("invalid user", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
}
}
}
}
private void btnlogin_out_Click(object sender, EventArgs e)
{
MDI md = new MDI();
md.Close();
}
private void Login___Master_Load(object sender, EventArgs e)
{
Dbclass obj = new Dbclass();
// grpfind.Visible = true;
string str = "Select * from user_master";
obj.Fillcombo(cmblogin_type , "user_type", "unq_id", str);
obj.Fillcombo(cmbuser_name , "user_name", "unq_id", str);
}
}
}
----------------------------------------------------------------------
Message Show
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
if (!bClosing)
{
bClosing = true;
if (MessageBox.Show("Are sure You want to exit?", "Exit?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
{
e.Cancel = true;
}
else
{
e.Cancel = false;
}
}
else
{
bClosing = false;
}
}
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
private void searchAllToolStripMenuItem_Click(object sender, EventArgs e)
{
Search srch = new Search();
srch.Show();
}
private void searchReportToolStripMenuItem_Click(object sender, EventArgs e)
{
SearchStatus srchst = new SearchStatus();
srchst.Show();
}
}
}
------------------------------------------------------------------------------
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;
using System.Data.SqlClient;
namespace Bar_nd_Hotel
{
public partial class crtVeg : Form
{
public crtVeg()
{
InitializeComponent();
}
AutoCompleteStringCollection codeCollection = new AutoCompleteStringCollection();
List<string> arraylistitm = new List<string>();
List<string> arraylistqty = new List<string>();
private void crtVeg_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'bar_dbDataSet3.category' table. You can move, or remove it, as needed.
this.categoryTableAdapter.Fill(this.bar_dbDataSet3.category);
// TODO: This line of code loads data into the 'bar_dbDataSet1.veg_category' table. You can move, or remove it, as needed.
//this.veg_categoryTableAdapter.Fill(this.bar_dbDataSet1.veg_category);
string constring = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con = new SqlConnection(constring);
string cmdstring = "select crt_categ from category where main_cat = 'Veg. Items'";
SqlCommand cmd = new SqlCommand(cmdstring, con);
con.Open();
SqlDataReader dr;
dr = cmd.ExecuteReader();
while (dr.Read())
{
vegcatcmb.Items.Add(dr["crt_categ"].ToString());
}
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "select distinct itm_code from crt_veg order by itm_code";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
con1.Open();
SqlDataReader dr1;
dr1 = cmd1.ExecuteReader();
if (dr1.HasRows == true)
{
while (dr1.Read())
{
codeCollection.Add(dr1["itm_code"].ToString());
}
}
dr1.Close();
vegcode.AutoCompleteMode = AutoCompleteMode.Suggest;
vegcode.AutoCompleteSource = AutoCompleteSource.CustomSource;
vegcode.AutoCompleteCustomSource = codeCollection;
}
private void button1_Click(object sender, EventArgs e)
{
arraylistitm.Add(itm1.Text);
arraylistitm.Add(itm2.Text);
arraylistitm.Add(itm3.Text);
arraylistitm.Add(itm4.Text);
arraylistitm.Add(itm5.Text);
arraylistitm.Add(itm6.Text);
arraylistitm.Add(itm7.Text);
arraylistitm.Add(itm8.Text);
arraylistitm.Add(itm9.Text);
arraylistitm.Add(itm10.Text);
arraylistqty.Add(qty1.Text);
arraylistqty.Add(qty2.Text);
arraylistqty.Add(qty3.Text);
arraylistqty.Add(qty4.Text);
arraylistqty.Add(qty5.Text);
arraylistqty.Add(qty6.Text);
arraylistqty.Add(qty7.Text);
arraylistqty.Add(qty8.Text);
arraylistqty.Add(qty9.Text);
arraylistqty.Add(qty10.Text);
int n = 0;
for (int j = 0; j < 10; j++)
{
if (arraylistitm[j].Length > 1)
{
n++;
}
}
for (int i = 0; i < n; i++)
{
if (i == 0)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm1.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm1.Text + "', '" +Convert.ToDateTime( DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name,date) values( '" + itm1.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "' ) ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 1)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm2.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm2.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "' ) ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name,date) values( '" + itm2.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 2)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm3.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm3.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm3.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 3)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm4.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm4.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm4.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 4)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm5.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm5.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm5.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 5)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm6.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm6.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm6.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 6)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm7.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm7.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm7.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 7)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm8.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm8.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm8.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 8)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm9.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm9.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm9.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
if (i == 9)
{
string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con2 = new SqlConnection(constring2);
string cmdstring2 = "select cnt_name from itm_invntry where cnt_name = '" + itm10.Text + "' ";
SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
con2.Open();
SqlDataReader dr2;
dr2=cmd2.ExecuteReader();
if (dr2.Read())
{
}
else
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm10.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
//string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm10.Text + "') ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
//SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
con1.Open();
cmd1.ExecuteNonQuery();
//cmd3.ExecuteNonQuery();
con1.Close();
}
}
}
string constring = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con = new SqlConnection(constring);
string cmdstring = "insert into crt_veg (itm_categ,itm_name,itm_code,itm_amt,itm1,qty1,itm2,qty2,itm3,qty3,itm4,qty4,itm5,qty5,itm6,qty6,itm7,qty7,itm8,qty8,itm9,qty9,itm10,qty10) values( '" + vegcatcmb.Text + "','" + vegname.Text + "', '" + Convert.ToInt32(vegcode.Text) + "', '" + vegamt.Text + "', '" + itm1.Text + "', '" + qty1.Text + "','" + itm2.Text + "', '" + qty2.Text + "','" + itm3.Text + "', '" + qty3.Text + "','" + itm4.Text + "', '" + qty4.Text + "','" + itm5.Text + "', '" + qty5.Text + "','" + itm6.Text + "', '" + qty6.Text + "','" + itm7.Text + "', '" + qty7.Text + "','" + itm8.Text + "', '" + qty8.Text + "','" + itm9.Text + "', '" + qty9.Text + "','" + itm10.Text + "', '" + qty10.Text + "') ";
SqlCommand cmd = new SqlCommand(cmdstring, con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
//for (int i = 0; i < n; i++)
//{
// string cmdstring1 = "insert into VegCntItems (itm_code,itm_name,itm_cnt_name,itm_cnt_qty,itm_amt) values( '" + vegcode.Text + "','" + vegname.Text + "' , '" + arraylistitm[i].ToString() + "', '" + arraylistqty[i].ToString() + "', '" + vegamt.Text + "') ";
// SqlCommand cmd1 = new SqlCommand(cmdstring1, con);
// con.Open();
// cmd1.ExecuteNonQuery();
// con.Close();
//}
MessageBox.Show("New Veg Items has Been Added Successfully ");
con.Close();
//vegcatcmb.Text = "";
//vegname.Text = "";
//vegcode.Text = "";
//vegamt.Text = "";
con.Close();
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
string constring = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con = new SqlConnection(constring);
string cmdstring = "update crt_veg set itm_name = '" + vegname.Text + "',itm_amt = '" + vegamt.Text + "', itm1 = '" + itm1.Text + "',qty1 = '" + qty1.Text + "', itm2 = '" + itm2.Text + "',qty2 = '" + qty2.Text + "', itm3 = '" + itm3.Text + "',qty3 = '" + qty3.Text + "', itm4 = '" + itm4.Text + "',qty4 = '" + qty4.Text + "', itm5 = '" + itm5.Text + "',qty5 = '" + qty5.Text + "', itm6 = '" + itm6.Text + "',qty6 = '" + qty6.Text + "', itm7 = '" + itm7.Text + "',qty7 = '" + qty7.Text + "', itm8 = '" + itm8.Text + "',qty8 = '" + qty8.Text + "', itm9 = '" + itm9.Text + "',qty9 = '" + qty9.Text + "' , itm10 = '" + itm10.Text + "',qty10 = '" + qty10.Text + "' where itm_categ = '" + vegcatcmb.Text + "' and itm_code = '" + vegcode.Text + "' ";
SqlCommand cmd = new SqlCommand(cmdstring, con);
con.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Item details has been Updated Successfully ");
con.Close();
//vegcatcmb.Text = "";
//vegname.Text = "";
//vegcode.Text = "";
//vegamt.Text = "";
con.Close();
this.Close();
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void qty6_TextChanged(object sender, EventArgs e)
{
}
private void vegcode_TextChanged(object sender, EventArgs e)
{
//int n = 0;
//string constring = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
//SqlConnection con = new SqlConnection(constring);
//string cmdstring = "select itm_code from VegCntItems where itm_code = '" + vegcode.Text + "'";
//SqlCommand cmd = new SqlCommand(cmdstring, con);
//con.Open();
//SqlDataReader dr;
//dr = cmd.ExecuteReader();
//while (dr.Read())
//{
// n++;
//}
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "select * from crt_veg where itm_code = '" + vegcode.Text + "'";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
con1.Open();
SqlDataReader dr1;
dr1 = cmd1.ExecuteReader();
if (dr1.Read())
{
vegname.Text = dr1["itm_name"].ToString();
vegamt.Text = dr1["itm_amt"].ToString();
vegcatcmb.Text = dr1["itm_categ"].ToString();
itm1.Text = dr1["itm1"].ToString();
qty1.Text = dr1["qty1"].ToString();
itm2.Text = dr1["itm2"].ToString();
qty2.Text = dr1["qty2"].ToString();
itm3.Text = dr1["itm3"].ToString();
qty3.Text = dr1["qty3"].ToString();
itm4.Text = dr1["itm4"].ToString();
qty4.Text = dr1["qty4"].ToString();
itm5.Text = dr1["itm5"].ToString();
qty5.Text = dr1["qty5"].ToString();
itm6.Text = dr1["itm6"].ToString();
qty6.Text = dr1["qty6"].ToString();
itm7.Text = dr1["itm7"].ToString();
qty7.Text = dr1["qty7"].ToString();
itm8.Text = dr1["itm8"].ToString();
qty8.Text = dr1["qty8"].ToString();
itm9.Text = dr1["itm9"].ToString();
qty9.Text = dr1["qty9"].ToString();
itm10.Text = dr1["itm10"].ToString();
qty10.Text = dr1["qty10"].ToString();
}
else
{
vegname.Text = "";
vegamt.Text = "";
itm1.Text = "";
qty1.Text = "";
itm2.Text = "";
qty2.Text = "";
itm3.Text = "";
qty3.Text = "";
itm4.Text = "";
qty4.Text = "";
itm5.Text = "";
qty5.Text = "";
itm6.Text = "";
qty6.Text = "";
itm7.Text = "";
qty7.Text = "";
itm8.Text = "";
qty8.Text = "";
itm9.Text = "";
qty9.Text = "";
itm10.Text = "";
qty10.Text = "";
}
}
private void vegcatcmb_SelectedIndexChanged(object sender, EventArgs e)
{
string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
SqlConnection con1 = new SqlConnection(constring1);
string cmdstring1 = "select itm_code from crt_veg where itm_categ = '" + vegcatcmb.Text + "' ";
SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
con1.Open();
SqlDataReader dr1;
dr1 = cmd1.ExecuteReader();
if (dr1.HasRows == true)
{
while (dr1.Read())
{
codeCollection.Add(dr1["itm_code"].ToString());
}
}
else
{
codeCollection.Clear();
}
dr1.Close();
vegcode.AutoCompleteMode = AutoCompleteMode.Suggest;
vegcode.AutoCompleteSource = AutoCompleteSource.CustomSource;
vegcode.AutoCompleteCustomSource = codeCollection;
}
}
}
No comments:
Post a Comment