public ActionResult Save(Models.VATGroupModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.VATGroupID == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDVATGroup code = _db.MDVATGroup.Where(p => p.VATGroupCode == data.VATGroupCode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.MDVATGroup.Add(new DAL.MDVATGroup
                        {
                            VATGroupID   = data.VATGroupID,
                            VATGroupCode = data.VATGroupCode,
                            AccCode      = data.AccCode,
                            VatRate      = data.VatRate,
                            VatType      = data.VatType,
                            ccode        = data.ccode
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.VATGroupID != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDVATGroup code = _db.MDVATGroup.Where(p => p.VATGroupCode == data.VATGroupCode && p.VATGroupID != data.VATGroupID).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.MDVATGroup edit = _db.MDVATGroup.Where(p => p.VATGroupID == data.VATGroupID).FirstOrDefault();

                        edit.VATGroupID   = data.VATGroupID;
                        edit.VATGroupCode = data.VATGroupCode;
                        edit.AccCode      = data.AccCode;
                        edit.VatRate      = data.VatRate;
                        edit.VatType      = data.VatType;

                        edit.ccode = data.ccode;
                        _db.SaveChanges();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }

            return(View(data));
        }
        public ActionResult DeleteVat(int VATGroupID)
        {
            if (VATGroupID != 0)
            {
                System.Web.HttpContext.Current.Application.Lock();

                DAL.MDVATGroup delete = _db.MDVATGroup.Where(p => p.VATGroupID == VATGroupID).FirstOrDefault();

                _db.MDVATGroup.Remove(delete);
                _db.SaveChanges();

                System.Web.HttpContext.Current.Application.UnLock();

                return(Json(true, JsonRequestBehavior.AllowGet));
            }

            return(Json(false, JsonRequestBehavior.AllowGet));
        }