Esempio n. 1
0
        public List <Customerbo> ViewCustomer()
        {
            SqlConnection con = new SqlConnection("server= intvmsql01; user id =PJ09TMS101_1718; database=DB09TMS101_1718;password= tcstvm");

            con.Open();

            SqlCommand cmd = new SqlCommand("sp_viewcustomer", con);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader reader = cmd.ExecuteReader();

            List <Customerbo> listbo = new List <Customerbo>();

            while (reader.Read())
            {
                Customerbo C = new Customerbo();
                C.Id      = Convert.ToInt32(reader["customerid"]);
                C.Name    = reader["cname"].ToString();
                C.Dob     = Convert.ToDateTime(reader["dob"]);
                C.Gender  = reader["gender"].ToString();
                C.Contact = Convert.ToInt64(reader["contact"]);
                C.City    = reader["city"].ToString();

                listbo.Add(C);
            }
            return(listbo);
        }
Esempio n. 2
0
        public int AddCustomer(Customerbo C)
        {
            SqlConnection con = new SqlConnection("server= intvmsql01; user id =PJ09TMS101_1718; database=DB09TMS101_1718;password= tcstvm");

            con.Open();

            SqlCommand cmd = new SqlCommand("sp_addcustomer_3", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@cn", C.Name);
            cmd.Parameters.AddWithValue("@g", C.Gender);
            cmd.Parameters.AddWithValue("@d", C.Dob);
            cmd.Parameters.AddWithValue("@cno", C.Contact);
            cmd.Parameters.AddWithValue("@c", C.City);
            cmd.Parameters.AddWithValue("@cid", 0);

            cmd.Parameters["@cid"].Direction = ParameterDirection.Output;
            int ra = cmd.ExecuteNonQuery();

            if (ra > 0)
            {
                int cid = Convert.ToInt32(cmd.Parameters["@cid"].Value);
                return(cid);
            }
            else
            {
                return(0);
            }

             
        }
Esempio n. 3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string   cn      = cname.Text;
            string   g       = ddlgender.SelectedItem.Value;
            DateTime d       = Convert.ToDateTime(dob.Text);
            long     contact = Convert.ToInt64(cno.Text);
            string   c       = city.Text;

            Customerbo      C  = new Customerbo(cn, g, d, contact, c);
            CustomerMethods CM = new CustomerMethods();

            int cid = CM.AddCustomer(C);

            if (cid > 0)
            {
                Label1.Text = "" + cid;
            }

            else
            {
                Response.Write("<script>alert('Error')</script>");
            }
        }