public static void giohang_insert(Gioihang gh) { using (SqlConnection cn = ConnectDataBase()) { using (SqlCommand cmd = new SqlCommand("sp_giohang_insert", cn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue(@"sogh", gh.Sogh); cmd.Parameters.AddWithValue(@"ngaylap", gh.Ngaylap); cmd.Parameters.AddWithValue(@"email", gh.Email); cmd.Parameters.AddWithValue(@"tenkh", gh.Tenkh); cmd.Parameters.AddWithValue(@"sdt", gh.Sdt); cmd.Parameters.AddWithValue(@"diachi", gh.Diachi); cmd.Parameters.AddWithValue(@"ghichu", gh.Ghichu); cmd.Parameters.AddWithValue(@"tinhtrang", gh.Tinhtrang); try { cmd.ExecuteNonQuery(); } catch (Exception) { } } } }
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; } }
public static void giohang_insert(Gioihang gh) { GioHangDAO.giohang_insert(gh); }