public int AddAcc(A_BO A) { SqlConnection con = new SqlConnection("server=intvmsql01;user id=PJ09TMS101_1718;password=tcstvm;database=DB09TMS101_1718"); con.Open(); SqlCommand cmd = new SqlCommand("sp_addaccount031", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@cid", A.C_ID1); cmd.Parameters.AddWithValue("@amnt", A.Amnt); cmd.Parameters.AddWithValue("@acc_type", A.Acc_type); cmd.Parameters.AddWithValue("@acc_id", 0); cmd.Parameters["@acc_id"].Direction = ParameterDirection.Output; int rowaffected = cmd.ExecuteNonQuery(); if (rowaffected > 0) { int acc_id = Convert.ToInt32(cmd.Parameters["@acc_id"].Value); return(acc_id); } else { return(0); } }
public List <A_BO> ViewAccount() { SqlConnection con = new SqlConnection("server=intvmsql01;user id=PJ09TMS101_1718;password=tcstvm;database=DB09TMS101_1718"); con.Open(); SqlCommand cmd = new SqlCommand("sp_viewaccount123", con); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader reader = cmd.ExecuteReader(); List <A_BO> lstacc = new List <A_BO>(); while (reader.Read()) { A_BO obj = new A_BO(); obj.Acc_id = Convert.ToInt64(reader["acc_id"]); obj.C_ID1 = Convert.ToInt16(reader["C_id"]); obj.Amnt = Convert.ToInt64(reader["amnt"]); obj.Acc_status = reader["acc_status"].ToString(); obj.Acc_type = reader["acc_type"].ToString(); lstacc.Add(obj); } return(lstacc); }
protected void Button1_Click(object sender, EventArgs e) { int C_ID = Convert.ToInt32(TextBox1.Text); double amnt = Convert.ToInt64(TextBox2.Text); string acc_type = DropDownList1.Text; DateTime dt = DateTime.Now; A_BO obj2 = new A_BO(C_ID, amnt, acc_type); C_DAL obj3 = new C_DAL(); int acc_id = obj3.AddAcc(obj2); if (acc_id > 0) { Response.Write("<script>alert('Your account id is:" + acc_id + "')</script>"); } else { Response.Write("<script>alert(''error)</script>"); } }