Exemplo n.º 1
0
 public IActionResult Post([FromBody] QuyetDinh qd)
 {
     qd.TrangThai = true;
     try
     {
         QuyetDinh tour = new QuyetDinh()
         {
             SoQuyetDinh      = qd.SoQuyetDinh,
             MaCBNV           = qd.MaCBNV,
             MaLoaiQuyetDinh  = qd.MaLoaiQuyetDinh,
             ThoiHan          = qd.ThoiHan,
             NgayBanHanh      = qd.NgayBanHanh,
             NoiDungQuyetDinh = qd.NoiDungQuyetDinh,
             HinhThuc         = qd.HinhThuc,
             TrangThai        = qd.TrangThai
         };
         _db.QuyetDinh.Add(tour);
         _db.SaveChanges();
         return(Ok("Them thanh cong"));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
        public ActionResult updateLoaiChamDut(String json)
        {
            dynamic js             = JObject.Parse(json);
            String  tenLoaiChamDut = js.tenLoaiChamDut;
            String  soQD           = js.soQD;
            String  ngayQD         = js.ngayQD;
            String  ngayCD         = js.ngayCD;
            int     soQD1          = Int32.Parse(soQD.Trim());

            using (QUANGHANHABCEntities db = new QUANGHANHABCEntities())
            {
                ChamDut_NhanVien nv = (from p in db.ChamDut_NhanVien where p.MaQuyetDinh == soQD1 select p).SingleOrDefault();
                nv.LoaiChamDut = tenLoaiChamDut;
                if (isValidateDateTime(ngayCD))
                {
                    nv.NgayChamDut = Convert.ToDateTime(ngayCD);
                }

                QuyetDinh cd = (from p in db.QuyetDinhs where p.SoQuyetDinh == soQD select p).SingleOrDefault();
                if (isValidateDateTime(ngayQD))
                {
                    cd.NgayQuyetDinh = Convert.ToDateTime(ngayQD);
                }


                db.SaveChanges();

                ViewBag.nameDepartment = "quanlyhoso";
                return(Json(new { success = true, draw = Request["draw"] }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 3
0
        public async Task <ActionResult <QuyetDinh> > PostQuyetDinh(QuyetDinh quyetDinh)
        {
            _context.QuyetDinh.Add(quyetDinh);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetQuyetDinh", new { id = quyetDinh.IdquyetDinh }, quyetDinh));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutQuyetDinh(int id, QuyetDinh quyetDinh)
        {
            if (id != quyetDinh.IdquyetDinh)
            {
                return(BadRequest());
            }

            _context.Entry(quyetDinh).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuyetDinhExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 5
0
 public IActionResult Post3(string id)
 {
     try{
         QuyetDinh del = _db.QuyetDinh.FirstOrDefault(x => x.SoQuyetDinh == id);
         del.TrangThai = false;
         _db.SaveChanges();
         return(Ok("Xoa thanh cong"));
     }
     catch {
         return(BadRequest());
     }
 }
Exemplo n.º 6
0
 public IActionResult Getcv(string id)
 {
     try
     {
         QuyetDinh model = _db.QuyetDinh.Find(id);
         return(Ok(model));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Exemplo n.º 7
0
 public bool add(QuyetDinh QuyetDinh)
 {
     try
     {
         db.QuyetDinh.Add(QuyetDinh);
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Có lỗi xảy ra: " + ex.Message);
     }
     return(false);
 }
Exemplo n.º 8
0
 public IActionResult Post2([FromBody] QuyetDinh cb, string id)
 {
     try{
         QuyetDinh edit = _db.QuyetDinh.FirstOrDefault(x => x.SoQuyetDinh == id);
         edit.MaCBNV           = cb.MaCBNV;
         edit.MaLoaiQuyetDinh  = cb.MaLoaiQuyetDinh;
         edit.NgayBanHanh      = cb.NgayBanHanh;
         edit.NoiDungQuyetDinh = cb.NoiDungQuyetDinh;
         edit.HinhThuc         = cb.HinhThuc;
         edit.ThoiHan          = cb.ThoiHan;
         _db.SaveChanges();
         return(Ok("Them thanh cong"));
     }
     catch {
         return(BadRequest());
     }
 }
Exemplo n.º 9
0
        public bool action(StateForm state)
        {
            if (state == StateForm.None)
            {
                this.quyetdinh = new QuyetDinh {
                    ngayQD = DateTime.Now
                };
                form.setObject(quyetdinh);
                return(true);
            }

            if (state == StateForm.New || state == StateForm.Edit)
            {
                quyetdinh.MaNV = (new handerNhanVien()).GetValue(cb_manv).ToString();
                if (form.isValidation())
                {
                    if (state == StateForm.New)
                    {
                        _data.add(quyetdinh);
                    }

                    if (state == StateForm.Edit)
                    {
                        _data.update(quyetdinh);
                    }
                }
                else
                {
                    MessageBox.Show(form.getErrors()[0]);
                    return(false);
                }
            }


            if (state == StateForm.Del)
            {
                _data.delete(quyetdinh);
            }
            this.quyetDinhBindingSource.DataSource = _data.getList();
            this.Refresh();
            return(true);
        }
Exemplo n.º 10
0
        public bool delete(QuyetDinh QuyetDinh)

        {
            try
            {
                var item = db.QuyetDinh.FirstOrDefault(t => t.SoQD == QuyetDinh.SoQD);
                if (item == null)
                {
                    MessageBox.Show("Không thấy nhân viên");
                }

                db.QuyetDinh.Remove(QuyetDinh);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi xảy ra: " + ex.Message);
            }
            return(false);
        }
Exemplo n.º 11
0
        public bool update(QuyetDinh QuyetDinh)
        {
            try
            {
                var item = db.QuyetDinh.FirstOrDefault(t => t.SoQD == QuyetDinh.SoQD);
                if (item == null)
                {
                    return(false);
                }


                db.Entry(QuyetDinh).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi xảy ra: " + ex.Message);
            }
            return(false);
        }
        public ActionResult TLHD(string id, string soQD, string lydo, string dateQD, string dateTLHD, string group1, string group2, string elseCase)
        {
            QUANGHANHABCEntities db = new QUANGHANHABCEntities();

            using (DbContextTransaction dbct = db.Database.BeginTransaction())
            {
                try
                {
                    string dateQDFix = "";
                    if (dateQD != null && !dateQD.Equals(""))
                    {
                        string[] arr1 = dateQD.Split('/');
                        for (int i = 0; i < arr1.Length; i++)
                        {
                            dateQDFix = arr1[1] + "/" + arr1[0] + "/" + arr1[2];
                        }
                    }
                    string[] arr2        = dateTLHD.Split('/');
                    string   dateTLHDFix = "";
                    for (int i = 0; i < arr2.Length; i++)
                    {
                        dateTLHDFix = arr2[1] + "/" + arr2[0] + "/" + arr2[2];
                    }
                    var emp = db.NhanViens.Where(x => x.MaNV == id).FirstOrDefault();
                    emp.TrangThaiLamViec = "Đã chấm dứt";
                    db.Entry(emp).State  = EntityState.Modified;

                    QuyetDinh qd = new QuyetDinh();
                    qd.SoQuyetDinh = soQD;
                    if (!dateQDFix.Equals("") && dateQDFix != null)
                    {
                        qd.NgayQuyetDinh = Convert.ToDateTime(dateQDFix);
                    }
                    db.QuyetDinhs.Add(qd);

                    ChamDut_NhanVien tlhd = new ChamDut_NhanVien();
                    tlhd.MaNV = id;
                    if (lydo.Equals("Đi đơn vị ngoài"))
                    {
                        tlhd.LoaiChamDut = group1;
                    }
                    else if (lydo.Equals("Các trường hợp khác"))
                    {
                        if (group2.Equals("on"))
                        {
                            tlhd.LoaiChamDut = elseCase;
                        }
                        else
                        {
                            tlhd.LoaiChamDut = group2;
                        }
                    }
                    else
                    {
                        tlhd.LoaiChamDut = lydo;
                    }
                    tlhd.NgayChamDut = Convert.ToDateTime(dateTLHDFix);
                    db.ChamDut_NhanVien.Add(tlhd);
                    db.SaveChanges();
                    dbct.Commit();
                    return(RedirectToAction("Search"));
                }
                catch (Exception)
                {
                    dbct.Rollback();
                    string output = "";
                    if (output == "")
                    {
                        output += "Vui lòng nhập ngày chấm dứt";
                    }
                    Response.Write(output);
                    return(new HttpStatusCodeResult(400));
                }
            }
        }
Exemplo n.º 13
0
 public void DataGridViewClick(object obj)
 {
     quyetdinh = (QuyetDinh)obj;
     form.setObject(this.quyetdinh);
     controlForm.setState(StateForm.Show);
 }