Beispiel #1
0
        public ActionResult SaveFactory(Models.FactoryModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.fac_id == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Factory code = _db.Factory.Where(p => p.fcode == data.fcode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.Factory.Add(new DAL.Factory
                        {
                            fcode  = data.fcode,
                            fname1 = data.fname1,
                            fname2 = data.fname2,
                            ccode  = data.ccode,
                            bcode  = data.bcode,
                            fcap   = data.fcap
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.fac_id != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Factory code = _db.Factory.Where(p => p.fcode == data.fcode && p.fac_id != data.fac_id).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.Factory edit = _db.Factory.Where(p => p.fac_id == data.fac_id).FirstOrDefault();
                        edit.fcode  = data.fcode;
                        edit.fname1 = data.fname1;
                        edit.fname2 = data.fname2;
                        edit.ccode  = data.ccode;
                        edit.bcode  = data.bcode;
                        edit.fcap   = data.fcap;

                        _db.SaveChanges();

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

            return(View(data));
        }
        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 SaveTranspArea(Models.TransportasionAreaModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.TranspAreaID == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDTranspArea code = _db.MDTranspArea.Where(p => p.TranspAreaCode == data.TranspAreaCode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.MDTranspArea.Add(new DAL.MDTranspArea
                        {
                            TranspAreaCode    = data.TranspAreaCode,
                            TranspAreaName    = data.TranspAreaName,
                            TranspAreaNameEng = data.TranspAreaNameEng,
                            Remark            = data.Remark,
                            ccode             = data.ccode
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.TranspAreaID != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDTranspArea code = _db.MDTranspArea.Where(p => p.TranspAreaCode == data.TranspAreaCode && p.TranspAreaID != data.TranspAreaID).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.MDTranspArea edit = _db.MDTranspArea.Where(p => p.TranspAreaID == data.TranspAreaID).FirstOrDefault();
                        edit.TranspAreaCode    = data.TranspAreaCode;
                        edit.TranspAreaName    = data.TranspAreaName;
                        edit.TranspAreaNameEng = data.TranspAreaNameEng;
                        edit.Remark            = data.Remark;
                        edit.ccode             = data.ccode;
                        _db.SaveChanges();

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

            return(View(data));
        }
        public ActionResult SaveEmployeeGroup(Models.EmployeeGroupModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.EmGroupID == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDEmGroup code = _db.MDEmGroup.Where(p => p.EmCode == data.EmCode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.MDEmGroup.Add(new DAL.MDEmGroup
                        {
                            EmCode         = data.EmCode,
                            EmGroupName    = data.EmGroupName,
                            EmGroupNameEng = data.EmGroupNameEng,
                            EmGroupNote    = data.EmGroupNote,
                            ccode          = data.ccode
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.EmGroupID != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDEmGroup code = _db.MDEmGroup.Where(p => p.EmCode == data.EmCode && p.EmGroupID != data.EmGroupID).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.MDEmGroup edit = _db.MDEmGroup.Where(p => p.EmGroupID == data.EmGroupID).FirstOrDefault();
                        edit.EmCode         = data.EmCode;
                        edit.EmGroupName    = data.EmGroupName;
                        edit.EmGroupNameEng = data.EmGroupNameEng;
                        edit.EmGroupNote    = data.EmGroupNote;
                        edit.ccode          = data.ccode;
                        _db.SaveChanges();

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

            return(View(data));
        }
        public ActionResult SaveSection(Models.SectionModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.sec_id == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Section code = _db.Section.Where(p => p.secode == data.secode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.Section.Add(new DAL.Section
                        {
                            secode  = data.secode,
                            sename1 = data.sename1,
                            sename2 = data.sename2,
                            ccode   = data.ccode,
                            dcode   = data.dcode
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.sec_id != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Section code = _db.Section.Where(p => p.secode == data.secode && p.sec_id != data.sec_id).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.Section edit = _db.Section.Where(p => p.sec_id == data.sec_id).FirstOrDefault();
                        edit.secode  = data.secode;
                        edit.sename1 = data.sename1;
                        edit.sename2 = data.sename2;
                        edit.ccode   = data.ccode;
                        edit.dcode   = data.dcode;
                        _db.SaveChanges();

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

            return(View(data));
        }
Beispiel #6
0
        public ActionResult SaveWarehouse(Models.WarehouseModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.bciid == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Warehouse code = _db.Warehouse.Where(p => p.wcode == data.wcode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.Warehouse.Add(new DAL.Warehouse
                        {
                            wcode  = data.wcode,
                            bcode  = data.bcode,
                            wtype  = data.wtype,
                            wname1 = data.wname1,
                            wname2 = data.wname2
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.bciid != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Warehouse code = _db.Warehouse.Where(p => p.wcode == data.wcode && p.bciid != data.bciid).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.Warehouse edit = _db.Warehouse.Where(p => p.bciid == data.bciid).FirstOrDefault();
                        edit.wcode  = data.wcode;
                        edit.bcode  = data.bcode;
                        edit.wtype  = data.wtype;
                        edit.wname1 = data.wname1;
                        edit.wname2 = data.wname2;
                        _db.SaveChanges();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }

            return(View(data));
        }
        public ActionResult SaveBookType(Models.BankBookType data)
        {
            if (!ModelState.IsValid)
            {
                if (data.BookTypeID == 0)
                {
                    _db = new  QSoft_WUEntities();
                    DAL.MDBankBookType code = _db.MDBankBookType.Where(p => p.BookTypeCode == data.BookTypeCode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.MDBankBookType.Add(new DAL.MDBankBookType
                        {
                            BookTypeCode    = data.BookTypeCode,
                            BookTypeName    = data.BookTypeName,
                            BookTypeNameEng = data.BookTypeNameEng,
                            Remark          = data.Remark
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.BookTypeID != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDBankBookType code = _db.MDBankBookType.Where(p => p.BookTypeCode == data.BookTypeCode && p.BookTypeID != data.BookTypeID).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.MDBankBookType edit = _db.MDBankBookType.Where(p => p.BookTypeID == data.BookTypeID).FirstOrDefault();
                        edit.BookTypeCode    = data.BookTypeCode;
                        edit.BookTypeName    = data.BookTypeName;
                        edit.BookTypeNameEng = data.BookTypeNameEng;
                        edit.Remark          = data.Remark;

                        _db.SaveChanges();

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

            return(View(data));
        }
        public ActionResult SaveProductGroup(Models.GroupProductModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.bciid == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Groupproduct code = _db.Groupproduct.Where(p => p.grpcode == data.grpcode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.Groupproduct.Add(new DAL.Groupproduct
                        {
                            grpcode  = data.grpcode,
                            grpname1 = data.grpname1,
                            grpname2 = data.grpname2,
                            ccode    = data.ccode
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.bciid != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Groupproduct code = _db.Groupproduct.Where(p => p.grpcode == data.grpcode && p.bciid != data.bciid).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.Groupproduct edit = _db.Groupproduct.Where(p => p.bciid == data.bciid).FirstOrDefault();
                        edit.grpcode  = data.grpcode;
                        edit.grpname1 = data.grpname1;
                        edit.grpname2 = data.grpname2;
                        edit.ccode    = data.ccode;
                        _db.SaveChanges();

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

            return(View(data));
        }
        public ActionResult SaveCauseOfReductionDebt(Models.CauseOfReductionDebtModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.CNRemarkTypeID == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDCNRemarkType code = _db.MDCNRemarkType.Where(p => p.CNRemarkTypeCode == data.CNRemarkTypeCode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.MDCNRemarkType.Add(new DAL.MDCNRemarkType
                        {
                            CNRemarkTypeCode  = data.CNRemarkTypeCode,
                            CNRemarkTypeName1 = data.CNRemarkTypeName1,
                            CNRemarkTypeName2 = data.CNRemarkTypeName2,
                            ccode             = data.ccode
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.CNRemarkTypeID != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDCNRemarkType code = _db.MDCNRemarkType.Where(p => p.CNRemarkTypeCode == data.CNRemarkTypeCode && p.CNRemarkTypeID != data.CNRemarkTypeID).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.MDCNRemarkType edit = _db.MDCNRemarkType.Where(p => p.CNRemarkTypeID == data.CNRemarkTypeID).FirstOrDefault();
                        edit.CNRemarkTypeCode  = data.CNRemarkTypeCode;
                        edit.CNRemarkTypeName1 = data.CNRemarkTypeName1;
                        edit.CNRemarkTypeName2 = data.CNRemarkTypeName2;
                        edit.ccode             = data.ccode;
                        _db.SaveChanges();

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

            return(View(data));
        }
        public ActionResult SaveVat(Models.VatDesModel data)
        {
            if (ModelState.IsValid)
            {
                DAL.MDVatDes edit = _db.MDVatDes.Where(p => p.VatDesID == data.VatDesID).FirstOrDefault();
                edit.Remark = data.Remark;



                _db.SaveChanges();

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

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

                DAL.MDTranspArea delete = _db.MDTranspArea.Where(p => p.TranspAreaID == TranspAreaID).FirstOrDefault();

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

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

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

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DeleteBrach(int b_id)
        {
            if (b_id != 0)
            {
                System.Web.HttpContext.Current.Application.Lock();

                DAL.Branch delete = _db.Branch.Where(p => p.b_id == b_id).FirstOrDefault();

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

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

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

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DeleteCauseOfReductionDebt(int CNRemarkTypeID)
        {
            if (CNRemarkTypeID != 0)
            {
                System.Web.HttpContext.Current.Application.Lock();

                DAL.MDCNRemarkType delete = _db.MDCNRemarkType.Where(p => p.CNRemarkTypeID == CNRemarkTypeID).FirstOrDefault();

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

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

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

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
Beispiel #14
0
        public ActionResult DeleteGroupCustomer(int gcusid)
        {
            if (gcusid != 0)
            {
                System.Web.HttpContext.Current.Application.Lock();

                DAL.Groupcustomer delete = _db.Groupcustomer.Where(p => p.gcusid == gcusid).FirstOrDefault();

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

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

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

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DeleteBusinessType(int BusiTypeID)
        {
            if (BusiTypeID != 0)
            {
                System.Web.HttpContext.Current.Application.Lock();

                DAL.MDBusiType delete = _db.MDBusiType.Where(p => p.BusiTypeID == BusiTypeID).FirstOrDefault();

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

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

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

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DeleteDepart(int?d_id)
        {
            if (d_id != 0)
            {
                System.Web.HttpContext.Current.Application.Lock();

                DAL.Depart delete = _db.Depart.Where(p => p.d_id == d_id).FirstOrDefault();

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

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

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

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
Beispiel #17
0
        public ActionResult DeleteScrapp(int scid)
        {
            if (scid != 0)
            {
                System.Web.HttpContext.Current.Application.Lock();

                DAL.Scrap delete = _db.Scrap.Where(p => p.scid == scid).FirstOrDefault();

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

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

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

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DeleteExpn(int ExpnID)
        {
            if (ExpnID != 0)
            {
                System.Web.HttpContext.Current.Application.Lock();

                DAL.MDExpn delete = _db.MDExpn.Where(p => p.ExpnID == ExpnID).FirstOrDefault();

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

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

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

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DeleteProductGroup(int bciid)
        {
            if (bciid != 0)
            {
                System.Web.HttpContext.Current.Application.Lock();

                DAL.Groupproduct delete = _db.Groupproduct.Where(p => p.bciid == bciid).FirstOrDefault();

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

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

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

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
Beispiel #20
0
        public ActionResult DeleteFactory(int fac_id)
        {
            if (fac_id != 0)
            {
                System.Web.HttpContext.Current.Application.Lock();

                DAL.Factory delete = _db.Factory.Where(p => p.fac_id == fac_id).FirstOrDefault();

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

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

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

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DeleteSupplierType(int SupplierTypeID)
        {
            if (SupplierTypeID != 0)
            {
                System.Web.HttpContext.Current.Application.Lock();

                DAL.MDSupplierType delete = _db.MDSupplierType.Where(p => p.SupplierTypeID == SupplierTypeID).FirstOrDefault();

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

                //_db.Entry(edit).State = EntityState.Modified;
                //_db.SaveChanges();

                System.Web.HttpContext.Current.Application.UnLock();
                return(Json(true, JsonRequestBehavior.AllowGet));
            }

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
        public ActionResult SaveSupplierType(Models.SupplierTypeModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.SupplierTypeID == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDSupplierType code = _db.MDSupplierType.Where(p => p.SupplierTypeCode == data.SupplierTypeCode && p.SupplierTypeID != data.SupplierTypeID).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.MDSupplierType.Add(new DAL.MDSupplierType
                        {
                            SupplierTypeID   = data.SupplierTypeID,
                            SupplierTypeCode = data.SupplierTypeCode,
                            SupplierTypeName = data.SupplierTypeName,
                            SupplierTypeENG  = data.SupplierTypeENG,
                            ccode            = data.ccode
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.SupplierTypeID != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDSupplierType code = _db.MDSupplierType.Where(p => p.SupplierTypeCode == data.SupplierTypeCode && p.SupplierTypeID != data.SupplierTypeID).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        //System.Web.HttpContext.Current.Application.Lock();

                        DAL.MDSupplierType edit = _db.MDSupplierType.Where(p => p.SupplierTypeID == data.SupplierTypeID).FirstOrDefault();

                        edit.SupplierTypeID   = data.SupplierTypeID;
                        edit.SupplierTypeCode = data.SupplierTypeCode;
                        edit.SupplierTypeName = data.SupplierTypeName;
                        edit.SupplierTypeENG  = data.SupplierTypeENG;
                        edit.ccode            = data.ccode;
                        //edit.Remark = data.Remark;

                        _db.SaveChanges();

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

            return(View(data));
        }
        public ActionResult SaveExpn(Models.ExpnModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.ExpnID == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDExpn code = _db.MDExpn.Where(p => p.ExpnCode == data.ExpnCode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.MDExpn.Add(new DAL.MDExpn
                        {
                            ExpnCode    = data.ExpnCode,
                            ExpnName    = data.ExpnName,
                            ExpnNameEng = data.ExpnNameEng,
                            Remark      = data.Remark,
                            ExpnType    = data.ExpnType,
                            AccID       = data.AccID,
                            ccode       = data.ccode
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.ExpnID != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDExpn code = _db.MDExpn.Where(p => p.ExpnCode == data.ExpnCode && p.ExpnID != data.ExpnID).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.MDExpn edit = _db.MDExpn.Where(p => p.ExpnID == data.ExpnID).FirstOrDefault();
                        edit.ExpnCode    = data.ExpnCode;
                        edit.ExpnName    = data.ExpnName;
                        edit.ExpnNameEng = data.ExpnNameEng;
                        edit.ccode       = data.ccode;
                        edit.ExpnType    = data.ExpnType;
                        edit.AccID       = data.AccID;
                        edit.Remark      = data.Remark;


                        _db.SaveChanges();

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

            return(View(data));
        }
        public ActionResult SaveExpn(Models.ReceivePlaceModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.DropShipID == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDReceivePlace code = _db.MDReceivePlace.Where(p => p.DropShipCode == data.DropShipCode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.MDReceivePlace.Add(new DAL.MDReceivePlace
                        {
                            DropShipID   = data.DropShipID,
                            DropShipCode = data.DropShipCode,
                            DropShipName = data.DropShipName,
                            Remark       = data.Remark,
                            Addr         = data.Addr,
                            District     = data.District,
                            Amphur       = data.Amphur,
                            Province     = data.Province,
                            PostCode     = data.PostCode,
                            Tel          = data.Tel,
                            Fax          = data.Fax,
                            Contact      = data.Contact,
                            ccode        = data.ccode
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.DropShipID != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDReceivePlace code = _db.MDReceivePlace.Where(p => p.DropShipCode == data.DropShipCode && p.DropShipID != data.DropShipID).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.MDReceivePlace edit = _db.MDReceivePlace.Where(p => p.DropShipID == data.DropShipID).FirstOrDefault();
                        edit.DropShipID   = data.DropShipID;
                        edit.DropShipCode = data.DropShipCode;
                        edit.DropShipName = data.DropShipName;
                        edit.Remark       = data.Remark;
                        edit.Addr         = data.Addr;
                        edit.District     = data.District;
                        edit.Amphur       = data.Amphur;
                        edit.Province     = data.Province;
                        edit.PostCode     = data.PostCode;
                        edit.Tel          = data.Tel;
                        edit.Fax          = data.Fax;
                        edit.Contact      = data.Contact;
                        edit.ccode        = data.ccode;
                        _db.SaveChanges();

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

            return(View(data));
        }
        public ActionResult SaveProduct(Models.Product_ICModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.prod_id == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Products code = _db.Products.Where(p => p.pcode == data.pcode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.Products.Add(new DAL.Products
                        {
                            pcode               = data.pcode,
                            pname1              = data.pname1,
                            pname11             = data.pname11,
                            pname2              = data.pname2,
                            pname21             = data.pname21,
                            ptype               = data.ptype,
                            pqty                = data.pqty,
                            pbook               = data.pbook,
                            pcost               = data.pcost,
                            grpcode             = data.grpcode,
                            wcode               = data.wcode,
                            pstatus             = data.pstatus,
                            pinactive           = data.pinactive,
                            psvat               = data.psvat,
                            ppvat               = data.ppvat,
                            pcst                = data.pcst,
                            prpt                = data.prpt,
                            ctype               = data.ctype,
                            stduid              = data.stduid,
                            buid                = data.buid,
                            suid                = data.suid,
                            stuid               = data.stuid,
                            stbuid              = data.stbuid,
                            stsuid              = data.stsuid,
                            bnum                = data.bnum,
                            snum                = data.snum,
                            stnum               = data.stnum,
                            stbnum              = data.stbnum,
                            stsnum              = data.stsnum,
                            u0s                 = data.u0s,
                            u1s                 = data.u1s,
                            u2s                 = data.u2s,
                            u3s                 = data.u3s,
                            u4s                 = data.u4s,
                            s1                  = data.s1,
                            s2                  = data.s2,
                            s3                  = data.s3,
                            s4                  = data.s4,
                            s5                  = data.s5,
                            s6                  = data.s6,
                            ss1                 = data.ss1,
                            ss2                 = data.ss2,
                            ss3                 = data.ss3,
                            ss4                 = data.ss4,
                            stddiscount         = data.stddiscount,
                            xprice              = data.xprice,
                            xname               = data.xname,
                            a1                  = data.a1,
                            a2                  = data.a2,
                            a3                  = data.a3,
                            a4                  = data.a4,
                            a5                  = data.a5,
                            b1                  = data.b1,
                            b2                  = data.b2,
                            b3                  = data.b3,
                            b4                  = data.b4,
                            b5                  = data.b5,
                            c1                  = data.c1,
                            c2                  = data.c2,
                            c3                  = data.c3,
                            c4                  = data.c4,
                            c5                  = data.c5,
                            d1                  = data.d1,
                            d2                  = data.d2,
                            d3                  = data.d3,
                            d4                  = data.d4,
                            d5                  = data.d5,
                            note1               = data.note1,
                            note2               = data.note2,
                            note3               = data.note3,
                            note4               = data.note4,
                            note5               = data.note5,
                            note6               = data.note6,
                            note7               = data.note7,
                            note8               = data.note8,
                            note9               = data.note9,
                            note10              = data.note10,
                            imgpath             = data.imgpath,
                            ccode               = data.ccode,
                            mstatus             = data.mstatus,
                            ltsale              = data.ltsale,
                            ltsend              = data.ltsend,
                            barcodeid           = data.barcodeid,
                            AmountSet           = data.AmountSet,
                            file_img            = data.file_img,
                            file_type           = data.file_type,
                            dayupSent           = data.dayupSent,
                            moq                 = data.moq,
                            st2uid              = data.st2uid,
                            st2num              = data.st2num,
                            LotSerialExpireFlag = data.LotSerialExpireFlag,
                            grpcode2            = data.grpcode2,
                            grpcode3            = data.grpcode3,
                            grpcode4            = data.grpcode4,
                            grpcode5            = data.grpcode5
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.prod_id != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Products code = _db.Products.Where(p => p.pcode == data.pcode && p.prod_id != data.prod_id).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.Products edit = _db.Products.Where(p => p.prod_id == data.prod_id).FirstOrDefault();

                        edit.pcode               = data.pcode;
                        edit.pname1              = data.pname1;
                        edit.pname11             = data.pname11;
                        edit.pname2              = data.pname2;
                        edit.pname21             = data.pname21;
                        edit.ptype               = data.ptype;
                        edit.pqty                = data.pqty;
                        edit.pbook               = data.pbook;
                        edit.pcost               = data.pcost;
                        edit.grpcode             = data.grpcode;
                        edit.wcode               = data.wcode;
                        edit.pstatus             = data.pstatus;
                        edit.pinactive           = data.pinactive;
                        edit.psvat               = data.psvat;
                        edit.ppvat               = data.ppvat;
                        edit.pcst                = data.pcst;
                        edit.prpt                = data.prpt;
                        edit.ctype               = data.ctype;
                        edit.stduid              = data.stduid;
                        edit.buid                = data.buid;
                        edit.suid                = data.suid;
                        edit.stuid               = data.stuid;
                        edit.stbuid              = data.stbuid;
                        edit.stsuid              = data.stsuid;
                        edit.bnum                = data.bnum;
                        edit.snum                = data.snum;
                        edit.stnum               = data.stnum;
                        edit.stbnum              = data.stbnum;
                        edit.stsnum              = data.stsnum;
                        edit.u0s                 = data.u0s;
                        edit.u1s                 = data.u1s;
                        edit.u2s                 = data.u2s;
                        edit.u3s                 = data.u3s;
                        edit.u4s                 = data.u4s;
                        edit.s1                  = data.s1;
                        edit.s2                  = data.s2;
                        edit.s3                  = data.s3;
                        edit.s4                  = data.s4;
                        edit.s5                  = data.s5;
                        edit.s6                  = data.s6;
                        edit.ss1                 = data.ss1;
                        edit.ss2                 = data.ss2;
                        edit.ss3                 = data.ss3;
                        edit.ss4                 = data.ss4;
                        edit.stddiscount         = data.stddiscount;
                        edit.xprice              = data.xprice;
                        edit.xname               = data.xname;
                        edit.a1                  = data.a1;
                        edit.a2                  = data.a2;
                        edit.a3                  = data.a3;
                        edit.a4                  = data.a4;
                        edit.a5                  = data.a5;
                        edit.b1                  = data.b1;
                        edit.b2                  = data.b2;
                        edit.b3                  = data.b3;
                        edit.b4                  = data.b4;
                        edit.b5                  = data.b5;
                        edit.c1                  = data.c1;
                        edit.c2                  = data.c2;
                        edit.c3                  = data.c3;
                        edit.c4                  = data.c4;
                        edit.c5                  = data.c5;
                        edit.d1                  = data.d1;
                        edit.d2                  = data.d2;
                        edit.d3                  = data.d3;
                        edit.d4                  = data.d4;
                        edit.d5                  = data.d5;
                        edit.note1               = data.note1;
                        edit.note2               = data.note2;
                        edit.note3               = data.note3;
                        edit.note4               = data.note4;
                        edit.note5               = data.note5;
                        edit.note6               = data.note6;
                        edit.note7               = data.note7;
                        edit.note8               = data.note8;
                        edit.note9               = data.note9;
                        edit.note10              = data.note10;
                        edit.imgpath             = data.imgpath;
                        edit.ccode               = data.ccode;
                        edit.mstatus             = data.mstatus;
                        edit.ltsale              = data.ltsale;
                        edit.ltsend              = data.ltsend;
                        edit.barcodeid           = data.barcodeid;
                        edit.AmountSet           = data.AmountSet;
                        edit.file_img            = data.file_img;
                        edit.file_type           = data.file_type;
                        edit.dayupSent           = data.dayupSent;
                        edit.moq                 = data.moq;
                        edit.st2uid              = data.st2uid;
                        edit.st2num              = data.st2num;
                        edit.LotSerialExpireFlag = data.LotSerialExpireFlag;
                        edit.grpcode2            = data.grpcode2;
                        edit.grpcode3            = data.grpcode3;
                        edit.grpcode4            = data.grpcode4;
                        edit.grpcode5            = data.grpcode5;

                        _db.SaveChanges();

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

            return(View(data));
        }
        public ActionResult SaveBrach(Models.BranchModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.b_id == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Branch code = _db.Branch.Where(p => p.bcode == data.bcode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.Branch.Add(new DAL.Branch
                        {
                            bcode     = data.bcode,
                            bname1    = data.bname1,
                            bname12   = data.bname12,
                            bname2    = data.bname2,
                            bname22   = data.bname22,
                            baddress1 = data.baddress1,
                            baddress2 = data.baddress2,
                            bzip      = data.bzip,
                            btel      = data.btel,
                            bfax      = data.bfax,
                            ccode     = data.ccode
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.b_id != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Branch code = _db.Branch.Where(p => p.bcode == data.bcode && p.b_id != data.b_id).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.Branch edit = _db.Branch.Where(p => p.b_id == data.b_id).FirstOrDefault();
                        edit.bcode     = data.bcode;
                        edit.bname1    = data.bname1;
                        edit.bname12   = data.bname12;
                        edit.bname2    = data.bname2;
                        edit.bname22   = data.bname22;
                        edit.baddress1 = data.baddress1;
                        edit.baddress2 = data.baddress2;
                        edit.bzip      = data.bzip;
                        edit.btel      = data.btel;
                        edit.bfax      = data.bfax;
                        edit.ccode     = data.ccode;

                        _db.SaveChanges();

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

            return(View(data));
        }
        public ActionResult SaveEmployee(Models.EmployeeModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.EmpID == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDEmployee code = _db.MDEmployee.Where(p => p.EmpCode == data.EmpCode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.MDEmployee.Add(new DAL.MDEmployee
                        {
                            EmpID          = data.EmpID,
                            EmpCode        = data.EmpCode,
                            EmpHead        = data.EmpHead,
                            EmpTitle       = data.EmpTitle,
                            EmpNameEng     = data.EmpNameEng,
                            EmpName        = data.EmpName,
                            EmpType        = data.EmpType,
                            Tel            = data.Tel,
                            Email          = data.Email,
                            EmpStartDate   = data.EmpStartDate,
                            EmpPromoteDate = data.EmpPromoteDate,
                            EmpResignDate  = data.EmpResignDate,
                            EmpAddr1       = data.EmpAddr1,
                            District       = data.District,
                            Amphur         = data.Amphur,
                            Province       = data.Province,
                            PostCode       = data.PostCode,
                            EmpStatus      = data.EmpStatus,
                            EmpTitleEng    = data.EmpTitleEng,
                            EmpSignature   = data.EmpSignature,
                            Username       = data.Username,
                            DeptID         = data.DeptID,
                            EmpGroupID     = data.EmpGroupID,
                            PostID         = data.PostID,
                            TaxID          = data.TaxID,
                            IDCard         = data.IDCard,
                            Remark         = data.Remark,
                            ccode          = data.ccode
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.EmpID != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDEmployee code = _db.MDEmployee.Where(p => p.EmpCode == data.EmpCode && p.EmpID != data.EmpID).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.MDEmployee edit = _db.MDEmployee.Where(p => p.EmpID == data.EmpID).FirstOrDefault();

                        edit.EmpID          = data.EmpID;
                        edit.EmpCode        = data.EmpCode;
                        edit.EmpHead        = data.EmpHead;
                        edit.EmpTitle       = data.EmpTitle;
                        edit.EmpNameEng     = data.EmpNameEng;
                        edit.EmpName        = data.EmpName;
                        edit.EmpType        = data.EmpType;
                        edit.Tel            = data.Tel;
                        edit.Email          = data.Email;
                        edit.EmpStartDate   = data.EmpStartDate;
                        edit.EmpPromoteDate = data.EmpPromoteDate;
                        edit.EmpResignDate  = data.EmpResignDate;
                        edit.EmpAddr1       = data.EmpAddr1;
                        edit.District       = data.District;
                        edit.Amphur         = data.Amphur;
                        edit.Province       = data.Province;
                        edit.PostCode       = data.PostCode;
                        edit.EmpStatus      = data.EmpStatus;
                        edit.EmpTitleEng    = data.EmpTitleEng;
                        edit.EmpSignature   = data.EmpSignature;
                        edit.Username       = data.Username;
                        edit.DeptID         = data.DeptID;
                        edit.EmpGroupID     = data.EmpGroupID;
                        edit.PostID         = data.PostID;
                        edit.TaxID          = data.TaxID;
                        edit.IDCard         = data.IDCard;
                        edit.Remark         = data.Remark;
                        edit.ccode          = data.ccode;
                        _db.SaveChanges();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            return(View());
        }
Beispiel #28
0
        public ActionResult Save(Models.CompanyModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.corp_id == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Corp code = _db.Corp.Where(p => p.ccode == data.ccode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.Corp.Add(new DAL.Corp
                        {
                            corp_id    = data.corp_id,
                            ccode      = data.ccode,
                            cname1     = data.cname1,
                            cname11    = data.cname11,
                            cname2     = data.cname2,
                            cname21    = data.cname21,
                            caddress1  = data.caddress1,
                            caddress2  = data.caddress2,
                            czip       = data.czip,
                            ctel       = data.ctel,
                            cfax       = data.cfax,
                            taxid      = data.taxid,
                            number1    = data.number1,
                            number2    = data.number2,
                            number3    = data.number3,
                            number4    = data.number4,
                            number5    = data.number5,
                            number6    = data.number6,
                            number7    = data.number7,
                            number8    = data.number8,
                            decimal1   = data.decimal1,
                            decimal2   = data.decimal2,
                            decimal3   = data.decimal3,
                            decimal4   = data.decimal4,
                            decimal5   = data.decimal5,
                            decimal6   = data.decimal6,
                            decimal7   = data.decimal7,
                            decimal8   = data.decimal8,
                            stockcount = data.stockcount
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }

            if (data.corp_id != 0)
            {
                _db = new QSoft_WUEntities();
                DAL.Corp code = _db.Corp.Where(p => p.ccode == data.ccode && p.corp_id != data.corp_id).FirstOrDefault();
                if (code != null)
                {
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    DAL.Corp edit = _db.Corp.Where(p => p.corp_id == data.corp_id).FirstOrDefault();

                    edit.corp_id    = data.corp_id;
                    edit.ccode      = data.ccode;
                    edit.cname1     = data.cname1;
                    edit.cname11    = data.cname11;
                    edit.cname2     = data.cname2;
                    edit.cname21    = data.cname21;
                    edit.caddress1  = data.caddress1;
                    edit.caddress2  = data.caddress2;
                    edit.czip       = data.czip;
                    edit.ctel       = data.ctel;
                    edit.cfax       = data.cfax;
                    edit.taxid      = data.taxid;
                    edit.number1    = data.number1;
                    edit.number2    = data.number2;
                    edit.number3    = data.number3;
                    edit.number4    = data.number4;
                    edit.number5    = data.number5;
                    edit.number6    = data.number6;
                    edit.number7    = data.number7;
                    edit.number8    = data.number8;
                    edit.decimal1   = data.decimal1;
                    edit.decimal2   = data.decimal2;
                    edit.decimal3   = data.decimal3;
                    edit.decimal4   = data.decimal4;
                    edit.decimal5   = data.decimal5;
                    edit.decimal6   = data.decimal6;
                    edit.decimal7   = data.decimal7;
                    edit.decimal8   = data.decimal8;
                    edit.stockcount = data.stockcount;
                    _db.SaveChanges();
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
            }


            return(View(data));
        }
        public ActionResult Save(Models.SupplierModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.sup_id == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Supplier code = _db.Supplier.Where(p => p.supcode == data.supcode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.Supplier.Add(new DAL.Supplier
                        {
                            sup_id        = data.sup_id,
                            supcode       = data.supcode,
                            supname1      = data.supname1,
                            supname11     = data.supname11,
                            supname2      = data.supname2,
                            supname21     = data.supname21,
                            supaddress1   = data.supaddress1,
                            supaddress2   = data.supaddress2,
                            supzip        = data.supzip,
                            suptel        = data.suptel,
                            supfax        = data.supfax,
                            supmobile     = data.supmobile,
                            dateinact     = data.dateinact,
                            status        = data.status,
                            p_id          = data.p_id,
                            t_id          = data.t_id,
                            niti          = data.niti,
                            acc_code      = data.acc_code,
                            gsupid        = data.gsupid,
                            contaddress1  = data.contaddress1,
                            contaddress2  = data.contaddress2,
                            contzip       = data.contzip,
                            notebill      = data.notebill,
                            noteth        = data.noteth,
                            noteen        = data.noteen,
                            credittermday = data.credittermday,
                            creditmoney   = data.creditmoney,
                            contname      = data.contname,
                            ncostcode     = data.ncostcode,
                            ndiscountcode = data.ndiscountcode,
                            note1         = data.note1,
                            note2         = data.note2,
                            note3         = data.note3,
                            note4         = data.note4,
                            note5         = data.note5,
                            note6         = data.note6,
                            note7         = data.note7,
                            note8         = data.note8,
                            note9         = data.note9,
                            note10        = data.note10,
                            ccode         = data.ccode
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.sup_id != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Supplier code = _db.Supplier.Where(p => p.supcode == data.supcode && p.sup_id != data.sup_id).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.Supplier edit = _db.Supplier.Where(p => p.sup_id == data.sup_id).FirstOrDefault();

                        edit.sup_id        = data.sup_id;
                        edit.supcode       = data.supcode;
                        edit.supname1      = data.supname1;
                        edit.supname11     = data.supname11;
                        edit.supname2      = data.supname2;
                        edit.supname21     = data.supname21;
                        edit.supaddress1   = data.supaddress1;
                        edit.supaddress2   = data.supaddress2;
                        edit.supzip        = data.supzip;
                        edit.suptel        = data.suptel;
                        edit.supfax        = data.supfax;
                        edit.supmobile     = data.supmobile;
                        edit.dateinact     = data.dateinact;
                        edit.status        = data.status;
                        edit.p_id          = data.p_id;
                        edit.t_id          = data.t_id;
                        edit.niti          = data.niti;
                        edit.acc_code      = data.acc_code;
                        edit.gsupid        = data.gsupid;
                        edit.contaddress1  = data.contaddress1;
                        edit.contaddress2  = data.contaddress2;
                        edit.contzip       = data.contzip;
                        edit.notebill      = data.notebill;
                        edit.noteth        = data.noteth;
                        edit.noteen        = data.noteen;
                        edit.credittermday = data.credittermday;
                        edit.creditmoney   = data.creditmoney;
                        edit.contname      = data.contname;
                        edit.ncostcode     = data.ncostcode;
                        edit.ndiscountcode = data.ndiscountcode;
                        edit.note1         = data.note1;
                        edit.note2         = data.note2;
                        edit.note3         = data.note3;
                        edit.note4         = data.note4;
                        edit.note5         = data.note5;
                        edit.note6         = data.note6;
                        edit.note7         = data.note7;
                        edit.note8         = data.note8;
                        edit.note9         = data.note9;
                        edit.note10        = data.note10;
                        edit.ccode         = data.ccode;
                        _db.SaveChanges();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }

            return(View(data));
        }
        public ActionResult SaveBankBrach(Models.BankBrach data)
        {
            if (!ModelState.IsValid)
            {
                if (data.BankBrchID == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDBankBrch code = _db.MDBankBrch.Where(p => p.BankBrchCode == data.BankBrchCode && p.BankBrchID != data.BankBrchID).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.MDBankBrch.Add(new DAL.MDBankBrch
                        {
                            BankBrchID      = data.BankBrchID,
                            BankBrchCode    = data.BankBrchCode,
                            BankBrchName    = data.BankBrchName,
                            BankBrchNameEng = data.BankBrchNameEng,
                            BankBrchAddr1   = data.BankBrchAddr1,
                            BankBrchAddr2   = data.BankBrchAddr2,
                            Remark          = data.Remark
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.BankBrchID != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDBankBrch code = _db.MDBankBrch.Where(p => p.BankBrchCode == data.BankBrchCode && p.BankBrchID != data.BankBrchID).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        //System.Web.HttpContext.Current.Application.Lock();

                        DAL.MDBankBrch edit = _db.MDBankBrch.Where(p => p.BankBrchID == data.BankBrchID).FirstOrDefault();

                        edit.BankBrchCode    = data.BankBrchCode;
                        edit.BankBrchName    = data.BankBrchName;
                        edit.BankBrchNameEng = data.BankBrchNameEng;
                        edit.BankBrchAddr1   = data.BankBrchAddr1;
                        edit.BankBrchAddr2   = data.BankBrchAddr2;
                        edit.Remark          = data.Remark;

                        _db.SaveChanges();

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

            return(View(data));
        }