3Lop_SP
==============SERVICE=========================
A_DAL A = new A_DAL();
void Add(Entites h)
{
A.Them(h.MA, h.TEN);
}
public void Add(int a, string b)
{
Entites h2 = new Entites();
h2.MA = a;
h2.TEN = b;
Add(h2);
}
===============DAL_LOGIC======================
public void Them(int a, string b)
{
SqlParameter[] p;
p = new SqlParameter[2];
p[0] = new SqlParameter("Ma", a);
p[0].SqlDbType = SqlDbType.Int;
p[1] = new SqlParameter("Ten", b);
p[1].SqlDbType = SqlDbType.NVarChar;
h.ExecuteNonQuerry("Them", p);
}
public int Layma()
{
return h.GetValueInt("LayMaNV");
}
=====================HELPER===================
public int GetValueInt(string proc)
{
cmd = new SqlCommand();
cmd.CommandText = proc;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = p.Connect();
int i = int.Parse(cmd.ExecuteScalar().ToString());
return i;
}
public void ExecuteNonQuerry(string proc, SqlParameter[] param)
{
cmd = new SqlCommand();
cmd.CommandText = proc;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddRange(param);
cmd.Connection = p.Connect();
cmd.ExecuteNonQuery();
}
==============MAIN=============
private void btnThem_Click(object sender, EventArgs e)
{
s.Them(int.Parse(txtManv.Text), txtTennv.Text, cboGioitinh.Text, mkngaysinh.Text, txtDiachi.Text, mkNgaylam.Text);
dgvNhanvien.DataSource = s.LoadDataGridView();
MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
Moi();
}
Bạn đang đọc truyện trên: Truyen247.Pro