public static string _sua(DMPhucap pc, string maloai) { string s = "update DMPhucap set maloaipc='" + pc.Maloaipc + "', tenloai=N'" + pc.Tenloai + "', tien='" + pc.Tien + "' where maloaipc='" + maloai + "'"; string sql = string.Format(s); return(DA.Ketnoi.ExcuteNonQuery(sql)); }
// select phu cap #region select phu cap public static List <DMPhucap> selectPhucap() { List <DTO.DMPhucap> pc = new List <DMPhucap>(); DataTable dt = new DataTable(); dt = DA.Ketnoi.ExcecuteQuery("Select * from DMPhucap"); for (int i = 0; i < dt.Rows.Count; i++) { DMPhucap pc1 = new DMPhucap(); pc1.Maloaipc = dt.Rows[i]["maloaipc"].ToString(); pc1.Tenloai = dt.Rows[i]["tenloai"].ToString(); pc1.Tien = dt.Rows[i]["tien"].ToString(); pc.Add(pc1); } return(pc); }
private void _insert() { DMPhucap pc = new DMPhucap(); pc.Maloaipc = txtMaloaipc.Text; pc.Tenloai = txtTenloaipc.Text; pc.Tien = txtTien.Text; if (kiemtraNhap()) { if (BUS.BUS_Phucap._insert(pc)) { MessageBox.Show("Thêm thành công"); reload(); this.Close(); } } }
public void Capnhat() { if (kiemtraNhap()) { DMPhucap pc = new DMPhucap(); pc.Maloaipc = txtMaloaipc.Text; pc.Tenloai = txtTenloaipc.Text; pc.Tien = txtTien.Text; if (BUS.BUS_Phucap._sua(pc, phucap.Maloaipc) == "true") { MessageBox.Show("Sửa thành công phụ cấp có mã " + txtMaloaipc.Text + "", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); reload(); this.Close(); } else { MessageBox.Show("Có lỗi từ hệ thống, hãy liên hệ với bộ phận kỹ thuật", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
// insert DmPhuCap #region them phu cap public static bool _insert(DMPhucap phucap) { try { DataTable dt = new DataTable("DMPhuCap"); SqlDataAdapter da = new SqlDataAdapter(); SqlCommand cm = new SqlCommand(); cm.Connection = DA.Ketnoi.Cmb(); cm.CommandType = CommandType.Text; cm.CommandText = @"insert into DMPhuCap(maloaipc,tenloai,tien) values (@maloaipc,@tenloai,@tien)"; cm.Parameters.Add("@maloaipc", SqlDbType.NVarChar, 10).Value = phucap.Maloaipc; cm.Parameters.Add("@tenloai", SqlDbType.NVarChar, 100).Value = phucap.Tenloai; cm.Parameters.Add("@tien", SqlDbType.Real).Value = phucap.Tien; da.SelectCommand = cm; da.Fill(dt); return(true); } catch { return(false); } }
// sua phu cap public static string _sua(DMPhucap pc, string maloai) { return(DAO.DAO_DMPhucap._sua(pc, maloai)); }
// them phu cap public static bool _insert(DMPhucap phucap) { return(DAO.DAO_DMPhucap._insert(phucap)); }
public frmSuaphucap(DMPhucap pc) { InitializeComponent(); this.phucap = pc; }