Example #1
0
        public static void CTGioHang_insert(ChitietGiohang ct)
        {
            using (SqlConnection cn = ConnectDataBase())
            {
                using (SqlCommand cmd = new SqlCommand("sp_ctgiohang_insert", cn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue(@"sogh", ct.Sogh);
                    cmd.Parameters.AddWithValue(@"mamh", ct.Mamh);
                    cmd.Parameters.AddWithValue(@"size", ct.Size);
                    cmd.Parameters.AddWithValue(@"sl", ct.Sl);
                    cmd.Parameters.AddWithValue(@"dgia", ct.Dongia);

                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
Example #2
0
    void create_insert_giohang()
    {
        Gioihang gh = new Gioihang();

        //giỏ hàng
        gh.Sogh      = sinh_sogh();
        gh.Ngaylap   = DateTime.Now;
        gh.Email     = function.email;
        gh.Tenkh     = txt_tenkhachhang.Text;
        gh.Sdt       = txt_sdtgiaohang.Text;
        gh.Diachi    = txt_diachigiaohang.Text;
        gh.Ghichu    = txt_ghichu.Text;
        gh.Tinhtrang = false;

        //CTGioHang

        GioHangBUS.giohang_insert(gh);

        if (Session["giohang"] != null)
        {
            DataTable dt_ctgh = Session["giohang"] as DataTable;
            foreach (DataRow r in dt_ctgh.Rows)
            {
                ChitietGiohang ct = new ChitietGiohang();

                ct.Sogh   = gh.Sogh;
                ct.Mamh   = r["mamh"].ToString();
                ct.Size   = r["size"].ToString();
                ct.Sl     = int.Parse(r["sl"].ToString());
                ct.Dongia = decimal.Parse(r["khuyenmai"].ToString());

                CTGioHangBUS.CTGioHang_insert(ct);
            }
            Session["giohang"] = null;
        }
    }
Example #3
0
 public static void CTGioHang_insert(ChitietGiohang ct)
 {
     CTGioHangDAO.CTGioHang_insert(ct);
 }