You are on page 1of 6

using using using using using using using using using using using

System; System.Data; System.Configuration; System.Collections; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Web.UI.HtmlControls; System.Data.SqlClient;

public partial class cashdepositoffice : System.Web.UI.Page { string date1 = DateTime.Now.ToString("dd-MM-yyyy"); string time1 = DateTime.Now.ToShortTimeString(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { //--To retrieve emp no. & Emp Dept to content page-//string result1 = Request.QueryString["EmpCode"]; //lblEmpCode.Text = result1; //string result2 = Request.QueryString["EmpDep"]; //lblDep.Text = result2; //string result3 = Request.QueryString["DeskNo"]; //lblCounter.Text = result3; string result1 = (string)(Session["SessionEmpCode"]); lblEmpCode.Text = result1; string result2 = (string)(Session["SessionEmpDep"]); lblDep.Text = result2; string result3 = (string)(Session["SessionDeskNo"]); lblCounter.Text = result3; Panel1.Visible = true; Panel2.Visible = false; //---Token(Dynamic) table Login set status---string db6 = ConfigurationManager.ConnectionStrings["connect"].C onnectionString; System.Data.SqlClient.SqlConnection con6 = new System.Data.SqlCl ient.SqlConnection(db6); con6.Open(); SqlCommand cmd6 = new SqlCommand("Update Token set Status ='Open ' where EmployeeId='" + lblEmpCode.Text + "' ", con6); cmd6.ExecuteNonQuery(); con6.Close();

//--//----------call customer string db2 = ConfigurationManager.ConnectionStrings["connect"].C onnectionString; System.Data.SqlClient.SqlConnection con2 = new System.Data.SqlCl ient.SqlConnection(db2); con2.Open(); SqlCommand cmd2 = new SqlCommand("Select Min(TokenNo) From Token CD where status = 'W' ", con2); SqlDataReader dr1 = cmd2.ExecuteReader(); if (dr1.Read()) { lblTokenNo.Text = dr1[0].ToString(); } con2.Close(); string db9 = ConfigurationManager.ConnectionStrings["connect"].C onnectionString; System.Data.SqlClient.SqlConnection con9 = new System.Data.SqlClient .SqlConnection(db9); con9.Open(); SqlCommand cmd9 = new SqlCommand("Select * From TokenCD where status = 'W' ", con9); SqlDataReader dr9 = cmd9.ExecuteReader(); if (dr9.Read()) { //----Table----set current customer status to P string db1 = ConfigurationManager.ConnectionStrings["connect"].C onnectionString; System.Data.SqlClient.SqlConnection con3 = new System.Data.SqlCl ient.SqlConnection(db1); con3.Open(); SqlCommand cmd3 = new SqlCommand("Update CashDeposit set Status = 'P' , CounterNo = '" + lblCounter.Text + "', EmployeeId ='" + lblEmpCode.Text + "', CalledTime = '" + time1 + "' where TokenNo='" + lblTokenNo.Text + "' and D ate = '" + date1 + "'", con3); cmd3.ExecuteNonQuery();

con3.Close(); //--Tokentable---------set current customer status to P string db4 = ConfigurationManager.ConnectionStrings["connect"].C onnectionString; System.Data.SqlClient.SqlConnection con4 = new System.Data.SqlCl ient.SqlConnection(db4);

con4.Open(); SqlCommand cmd4 = new SqlCommand("Update TokenCD set Status = 'P ' , CounterNo = '" + lblCounter.Text + "', EmployeeId ='" + lblEmpCode.Text + "' , CalledTime = '" + time1 + "' where TokenNo='" + lblTokenNo.Text + "'", con4); cmd4.ExecuteNonQuery(); con4.Close(); //---Token(Dynamic) table---string db5 = ConfigurationManager.ConnectionStrings["connect"].C onnectionString; System.Data.SqlClient.SqlConnection con5 = new System.Data.SqlCl ient.SqlConnection(db5); con5.Open(); SqlCommand cmd5 = new SqlCommand("Update Token set TokenNo ='" + lblTokenNo.Text + "' where EmployeeId='" + lblEmpCode.Text + "' ", con5); cmd5.ExecuteNonQuery(); con5.Close(); //----TokenScreen-TokenScreen(); //----Token screen End-} else { //----TokenScreen-TokenScreen(); //----Token screen End-ClientScript.RegisterStartupScript(GetType(), "ShowAlert", "aler t('Token Table Empty');", true); } } catch (Exception ex) { ClientScript.RegisterStartupScript(GetType(), "ShowAlert", "aler t('ERROR : " + ex.StackTrace.ToString() + " ');", true); } } } public void TokenScreen() { int ctr1 = 0; //----TokenScreen-string db10 = ConfigurationManager.ConnectionStrings["connect"].Connecti onString; System.Data.SqlClient.SqlConnection con1 = new System.Data.SqlClient.Sql

Connection(db10); con1.Open(); SqlCommand cmd = new SqlCommand("Select Count(*) From TokenCD where sta tus != 'C' and status != 'P'", con1); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { ctr1 = Convert.ToInt32(dr[0].ToString()); } if (ctr1 >= 1) { lblTokenCount.Text = "*"; } else { lblTokenCount.Text = ""; } con1.Close(); DataRow row; DataTable dt = new DataTable(); DataSet ds = new DataSet("TokenScreen"); string db = ConfigurationManager.ConnectionStrings["connect"].Connection String; System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlC onnection(db); con.Open(); SqlDataAdapter adp = new SqlDataAdapter("select * from TokenScreen", con ); SqlCommandBuilder build = new SqlCommandBuilder(adp); adp.Fill(ds, "TokenScreen"); dt = ds.Tables["TokenScreen"]; row = ds.Tables["TokenScreen"].NewRow(); row["Department"] = lblDep.Text; row["Token_No"] = lblTokenNo.Text; row["Token_Count"] = lblTokenCount.Text; row["Counter_No"] = lblCounter.Text; ds.Tables["TokenScreen"].Rows.Add(row); adp.Update(ds, "TokenScreen"); con.Close(); //----Token screen End-} protected void Button2_Click(object sender, EventArgs e) { if(lblTokenNo.Text != "") { Panel1.Visible = false; Panel2.Visible = true; } else {

ClientScript.RegisterStartupScript(GetType(), "ShowAlert", "alert('T oken No. is empty');", true); } } protected void Button4_Click(object sender, EventArgs e) { if (DDLAcType.SelectedValue.ToString() == "Saving A/c") { updateAccount("SavingAccount"); } else if (DDLAcType.SelectedValue.ToString() == "Current A/c") { updateAccount("CurrentAccount"); } else { ClientScript.RegisterStartupScript(GetType(), "ShowAlert", "alert('I nvalid Selection');", true); } //--------} public void updateAccount(string Acc) { try { //--Saving/Current A/c Table-string db2 = ConfigurationManager.ConnectionStrings["connect"].Conne ctionString; System.Data.SqlClient.SqlConnection con2 = new System.Data.SqlClient .SqlConnection(db2); con2.Open(); txtTotalBal.Text = ""; int amt = Convert.ToInt32(txtAvailableBal1.Text) + Convert.ToInt32(t xtDepositAmt.Text); txtTotalBal.Text = Convert.ToString(amt); SqlCommand cmd2 = new SqlCommand("Update " + Acc + " set AvailableBa lance='" + txtTotalBal.Text + "' where AccountNo='" + txtAcNo.Text + "'", con2); cmd2.ExecuteNonQuery(); // ClientScript.RegisterStartupScript(GetType(), "ShowAlert", "alert ('Amount Deposited in to A/c No. " + txtAcNo.Text + " ');", true); txtAvailableBal.Text = ""; txtAvailableBal.Text = txtTotalBal.Text; con2.Close(); //--Cashdeposit Table---string db3 = ConfigurationManager.ConnectionStrings["connect"].Conne ctionString; System.Data.SqlClient.SqlConnection con3 = new System.Data.SqlClient .SqlConnection(db3); con3.Open();

SqlCommand cmd3 = new SqlCommand("Update CashDeposit set AccountNo=' " + txtAcNo.Text + "', AmountDeposit = '" + txtDepositAmt.Text + "' where TokenN o='" + lblTokenNo.Text+"'", con3); cmd3.ExecuteNonQuery(); ClientScript.RegisterStartupScript(GetType(), "ShowAlert", "alert('A mount Deposited in to A/c No. " + txtAcNo.Text + " ');", true); con3.Close(); } catch (Exception ex) { ClientScript.RegisterStartupScript(GetType(), "ShowAlert", "'ERROR: " + ex.StackTrace.ToString() + " ');", true); } }

You might also like