public string InsertHDN(EC_HOADONNHAP et) { string sql = "ThemHDN"; SqlConnection con = new SqlConnection(KetNoiDB.getconnect()); con.Open(); SqlCommand cmd = new SqlCommand(sql, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@mancc", et.MaNCC); cmd.Parameters.AddWithValue("@ngaynhap", et.NgayNhap); SqlDataAdapter ad = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); ad.Fill(dt); string ma = dt.Rows[0].ItemArray[0].ToString(); cmd.Dispose(); con.Close(); if (ma != null) { return(ma); } return("error"); }
public void UpdateHDN(EC_HOADONNHAP et) { string sql = "SuaHDN"; SqlConnection con = new SqlConnection(KetNoiDB.getconnect()); con.Open(); SqlCommand cmd = new SqlCommand(sql, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@mahdn", et.MaHDN); cmd.Parameters.AddWithValue("@mancc", et.MaNCC); cmd.Parameters.AddWithValue("@ngaynhap", et.NgayNhap); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }
public string InsertHDN(EC_HOADONNHAP et) { string sql = "ThemHDN"; SqlConnection con = new SqlConnection(KetNoiDB.getconnect()); con.Open(); SqlCommand cmd = new SqlCommand(sql, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@mancc", et.MaNCC); cmd.Parameters.AddWithValue("@ngaynhap", et.NgayNhap); SqlDataAdapter ad = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); ad.Fill(dt); string ma = dt.Rows[0].ItemArray[0].ToString(); cmd.Dispose(); con.Close(); if (ma != null) return ma; return "error"; }
public void UpdateHDN(EC_HOADONNHAP et) { string sql = "SuaHDN"; SqlConnection con = new SqlConnection(KetNoiDB.getconnect()); con.Open(); SqlCommand cmd = new SqlCommand(sql, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@mahdn", et.MaHDN); cmd.Parameters.AddWithValue("@mancc", et.MaNCC); cmd.Parameters.AddWithValue("@ngaynhap", et.NgayNhap); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }