public bool insertLuong(DTO_Luong luong) { try { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "sp_InsertDataIntoLuong"; cmd.Parameters.AddWithValue("bacLuong", luong.bacLuong); cmd.Parameters.AddWithValue("luongCB", luong.luongCoBan); cmd.Parameters.AddWithValue("heSoLuong", luong.heSoLuong); cmd.Parameters.AddWithValue("heSoPhuCap", luong.heSoPhuCap); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception) { } finally { conn.Close(); } return(false); }
private void btSua_Click(object sender, EventArgs e) { if (txtBacLuong.Text != "" && txtLuongCoBan.Text != "" && txtHeSoLuong.Text != "" && txtHeSoPhuCap.Text != "") { double l, hsluong, hspc; bool isLuong = double.TryParse(txtLuongCoBan.Text, out l); bool ishsluong = double.TryParse(txtHeSoLuong.Text, out hsluong); bool ishspc = double.TryParse(txtHeSoPhuCap.Text, out hspc); if (!isLuong || double.Parse(txtLuongCoBan.Text) < 0) { MessageBox.Show("Mời kiểm tra lương", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtLuongCoBan.Focus(); } else if (!ishsluong || double.Parse(txtHeSoLuong.Text) < 0) { MessageBox.Show("Mời kiểm tra hệ số lương", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtHeSoLuong.Focus(); } else if (!ishspc || double.Parse(txtHeSoPhuCap.Text) < 0) { MessageBox.Show("Mời kiểm tra hệ số phụ cấp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtHeSoPhuCap.Focus(); } else { DTO_Luong luong = new DTO_Luong(txtBacLuong.Text, double.Parse(txtLuongCoBan.Text), double.Parse(txtHeSoLuong.Text), double.Parse(txtHeSoPhuCap.Text));; if (MessageBox.Show("Bạn có chắc muốn sửa", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (busLuong.updateLuong(luong)) { MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadGridView_Luong(); CloseTextbox(); } else { MessageBox.Show("Sửa không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } else { MessageBox.Show("Xin hãy nhập đầy đủ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public bool updateLuong(DTO_Luong luong) { return(dalLuong.updateLuong(luong)); }
public bool insertLuong(DTO_Luong luong) { return(dalLuong.insertLuong(luong)); }