Пример #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            int           ma = int.Parse(this.dataGridViewLuong.CurrentRow.Cells[0].Value.ToString());
            luongnhanvien dt = db.luongnhanviens.Single(s => s.ma.Equals(ma));

            if (this.tbxMaNV_L.Text.Length != 0)
            {
                dt.nhanvienma = tbxMaNV_L.Text;
            }
            if (this.tbxMaLCB.Text.Length != 0)
            {
                dt.luongcobanma = this.tbxMaLCB.Text;
            }
            if (this.tbxMaPC.Text.Length != 0)
            {
                dt.phucapma = this.tbxMaPC.Text;
            }
            if (this.tbxIDLuong.Text.Length != 0)
            {
                dt.ma = this.tbxIDLuong.Text;
            }
            if (this.tbxNgayCong.Text.Length != 0)
            {
                dt.SoNgayCong = Int32.Parse(tbxNgayCong.Text);
            }
            if (this.tbcGioLamThem.Text.Length != 0)
            {
                dt.SoGioLamThem = Int32.Parse(tbcGioLamThem.Text);
            }
            if (this.tbxThuong.Text.Length != 0)
            {
                dt.Thuong = Int32.Parse(tbxThuong.Text);
            }
            if (this.tbxTamUng.Text.Length != 0)
            {
                dt.TamUng = Int32.Parse(tbxTamUng.Text);
            }
            dt.NgayLap = DateTime.Parse(dtpkNgayLapLuong.Text);

            db.SaveChanges();
        }
Пример #2
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            String       ma = this.dataGridViewLuong.CurrentRow.Cells[0].Value.ToString();
            DialogResult dr = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.YesNo);

            if (dr == System.Windows.Forms.DialogResult.Yes)
            {
                try
                {
                    luongnhanvien h = db.luongnhanviens.Single(s => s.ma.Equals(ma));
                    db.luongnhanviens.Remove(h);
                    db.SaveChanges();
                    MessageBox.Show("Delete Success");
                }
                catch
                {
                    MessageBox.Show("Delete fail!!");
                }
            }

            Save();
        }
Пример #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                luongnhanvien luongnv = new luongnhanvien();
                luongnv.nhanvienma   = this.tbxMaNV_L.Text;
                luongnv.ma           = this.tbxIDLuong.Text;
                luongnv.phucapma     = this.tbxMaPC.Text;
                luongnv.luongcobanma = this.tbxMaLCB.Text;
                luongnv.SoNgayCong   = Int32.Parse(tbxNgayCong.Text);
                luongnv.SoGioLamThem = Int32.Parse(tbcGioLamThem.Text);
                luongnv.Thuong       = Int32.Parse(tbxThuong.Text);
                luongnv.TamUng       = Int32.Parse(tbxTamUng.Text);

                db.luongnhanviens.Add(luongnv);
                MessageBox.Show("Thêm Thành Công!!!");
            }
            catch
            {
                MessageBox.Show("Thêm Thất bại!!");
            }
            Save();
        }