Ejemplo n.º 1
0
 public int UpdateChuyenPhi(
     int A_HOSOKHACHHANG_CHUYEN,
     int?A_KEHOACH_CHUYEN,
     int A_HOSOKHACHHANG_NHAN,
     int?A_KEHOACH_NHAN,
     decimal?SOTIEN,
     int?SOBUOICON,
     decimal DONGIABUOI,
     int?A_SANPHAM_NHAN,
     int A_TH_HOPDONG_NHAN,
     int?A_SANPHAM_CHUYEN,
     int A_TH_HOPDONG_CHUYEN,
     DateTime?NGAYBATDAU_CHUYEN,
     DateTime?NGAYCHUYEN,
     DateTime?NGAYBATDAU_NHAN,
     DateTime?NHAYKETTHUC_NHAN,
     int?SOBUOINHAN,
     decimal?DONGIACHUYEN,
     decimal?DONGIANHAN,
     decimal?ThanhTien,
     int?HinhThucChuyenPhi,
     int?A_DUBAO_XEPLOP)
 {
     try
     {
         int           sc = 0, ec = 0;
         APAXEntities3 db = new APAXEntities3();
         db.TH_DUBAO.Add(new TH_DUBAO()
         {
             J_HOSOKHACHHANG = A_HOSOKHACHHANG_CHUYEN,
             J_TH_HOPDONG    = A_TH_HOPDONG_CHUYEN,
             ID_DTTC         = FCVDataProvider.GetUserID(User.Identity.Name),
             DULIEUNHOM      = true,
             J_KEHOACH       = A_KEHOACH_CHUYEN,
             NGAYLAM         = DateTime.Now,
             NGAYGIAOHANG    = NGAYBATDAU_CHUYEN,
             NGAYTHANHTOAN   = NGAYCHUYEN,
             SOBUOI          = SOBUOICON,
             TONGTIEN_DH     = SOTIEN,
             ID_LYDO_HV      = 99,
             ID_THAIDO       = HinhThucChuyenPhi,
             ID_LYDO_TD      = 241
         });
         sc += db.SaveChanges();
         if (sc > 0)
         {
             int a_th_dubao = db.TH_DUBAO.OrderByDescending(t => t.A_TH_DUBAO).FirstOrDefault().A_TH_DUBAO;
             db.TH_DUBAO_SANPHAM.Add(new TH_DUBAO_SANPHAM()
             {
                 J_TH_DUBAO = a_th_dubao,
                 J_SANPHAM  = A_SANPHAM_CHUYEN > 0?(int)A_SANPHAM_CHUYEN:0,
                 SOLUONG    = SOBUOICON == null ? 0 : decimal.Parse(SOBUOICON.ToString()),
                 DONGIA     = SOTIEN,
                 THANHTIEN  = SOTIEN * (SOBUOICON == null ? 0 : decimal.Parse(SOBUOICON.ToString())),
             });
             sc += db.SaveChanges();
             if (sc >= 2)
             {
                 db.TH_DUBAO.Add(new TH_DUBAO()
                 {
                     J_HOSOKHACHHANG = A_HOSOKHACHHANG_NHAN,
                     J_TH_HOPDONG    = A_TH_HOPDONG_NHAN,
                     ID_DTTC         = FCVDataProvider.GetUserID(User.Identity.Name),
                     DULIEUNHOM      = true,
                     J_KEHOACH       = A_KEHOACH_NHAN,
                     NGAYLAM         = DateTime.Now,
                     NGAYGIAOHANG    = NGAYBATDAU_NHAN,
                     NGAYTHANHTOAN   = NHAYKETTHUC_NHAN,
                     SOBUOI          = SOBUOICON,
                     TONGTIEN_DH     = SOTIEN,
                     ID_THAIDO       = HinhThucChuyenPhi,
                     ID_LYDO_HV      = 1103,
                     ID_LYDO_TD      = 241,
                     A_THUCHIEN      = a_th_dubao
                 });
                 ec += db.SaveChanges();
                 if (ec > 0)
                 {
                     int a_th_dubaonhan = db.TH_DUBAO.OrderByDescending(t => t.A_TH_DUBAO).FirstOrDefault().A_TH_DUBAO;
                     db.TH_DUBAO_SANPHAM.Add(new TH_DUBAO_SANPHAM()
                     {
                         J_TH_DUBAO = a_th_dubaonhan,
                         J_SANPHAM  = A_SANPHAM_NHAN > 0?(int)A_SANPHAM_NHAN:0,
                         SOLUONG    = SOBUOINHAN == null ? 0 : decimal.Parse(SOBUOINHAN.ToString()),
                         DONGIA     = DONGIANHAN,
                         THANHTIEN  = DONGIANHAN * (SOBUOINHAN == null ? 0 : decimal.Parse(SOBUOINHAN.ToString())),
                     });
                     ec += db.SaveChanges();
                     TH_DUBAO DUBAO = db.TH_DUBAO.FirstOrDefault(st => st.A_TH_DUBAO == A_DUBAO_XEPLOP);
                     DUBAO.ID_TRANGTHAI    = 1;
                     db.Entry(DUBAO).State = EntityState.Modified;
                     sc += db.SaveChanges();
                 }
             }
             else
             {
                 return(0);
             }
         }
         //db.TH_THUTIEN.Add(new TH_THUTIEN()
         //{
         //    J_HOSOKHACHHANG = A_HOSOKHACHHANG_NHAN,
         //    J_TH_HOPDONG = A_TH_HOPDONG_NHAN,
         //    NGAYTHUTIEN = DateTime.Now,
         //    SOTIENTHU = SOTIEN,
         //    ID_LOAIPHIEUTHU = 3,
         //    ID_DTTC = FCVDataProvider.GetUserID(User.Identity.Name),
         //    MATHUTIEN = "1111",
         //    DULIEUNHOM = true
         //});
         //sc += db.Database.ExecuteSqlCommand("UPDATE dbo.TH_DUBAO SET NGAYTHANHTOAN = GETDATE(), ID_LYDO_TD = 240 WHERE J_HOSOKHACHHANG= '" + A_HOSOKHACHHANG_CHUYEN + "' AND J_KEHOACH = '" + A_KEHOACH_CHUYEN + "'");
         //db.SaveChanges();
         return(sc);
     }
     catch
     {
         return(0);
     }
 }
Ejemplo n.º 2
0
        public JsonResult SaveDuyetChuyenPhi(int?A_THDUBAO, int?IDDuyet, string NoiDung, int?Buoi1, int?Buoi2, int?KhuVuc, int?A_DuBao_XepLopChuyen, int?A_DuBao_XepLopNhan)
        {
            int sc = 0;

            try
            {
                TH_DUBAO model  = db.TH_DUBAO.FirstOrDefault(it => it.A_THUCHIEN == A_THDUBAO); //hoc sinh nhan phi
                TH_DUBAO model1 = db.TH_DUBAO.FirstOrDefault(it => it.A_TH_DUBAO == A_THDUBAO); //hoc sinh chuyen phi
                if (model1 != null)
                {
                    //them duyet vao hoc sinh chuyen
                    TH_DUYETTHUCHIEN New = new TH_DUYETTHUCHIEN()
                    {
                        J_TH_DUBAO  = A_THDUBAO,
                        ID_DTTC     = clsFunctions.GetUserID(),
                        NGAYDUYET   = DateTime.Now,
                        ID_DUYET    = IDDuyet,
                        YKIENBOSUNG = NoiDung
                    };
                    db.Set <TH_DUYETTHUCHIEN>().Add(New);
                    sc += db.SaveChanges();
                    if (sc > 0)
                    {
                        sc += db.Database.ExecuteSqlCommand("Update TH_DUBAO set ID_LYDO_TD = 242 where A_TH_DUBAO =" + A_THDUBAO);
                    }
                    //them duyet vao hoc sinh nhan
                    TH_DUYETTHUCHIEN New1 = new TH_DUYETTHUCHIEN()
                    {
                        J_TH_DUBAO  = model.A_TH_DUBAO,
                        ID_DTTC     = clsFunctions.GetUserID(),
                        NGAYDUYET   = DateTime.Now,
                        ID_DUYET    = IDDuyet,
                        YKIENBOSUNG = NoiDung
                    };
                    db.Set <TH_DUYETTHUCHIEN>().Add(New1);
                    sc += db.SaveChanges();
                    if (sc > 1)
                    {
                        sc += db.Database.ExecuteSqlCommand("Update TH_DUBAO set ID_LYDO_TD = 242 where A_TH_DUBAO =" + model.A_TH_DUBAO);
                    }
                    if (IDDuyet == 1)
                    {
                        //update vao du bao xep lop hoc sinh chuyen
                        TH_DUBAO HSChuyen = db.TH_DUBAO.FirstOrDefault(it => it.A_TH_DUBAO == A_DuBao_XepLopChuyen);
                        HSChuyen.NGAYTHANHTOAN   = model1.NGAYTHANHTOAN;
                        HSChuyen.SOBUOI          = HSChuyen.SOBUOI - model1.SOBUOI;
                        HSChuyen.TONGTIEN_DH     = HSChuyen.TONGTIEN_DH - model1.TONGTIEN_DH;
                        HSChuyen.ID_TRANGTHAI    = 1;
                        db.Entry(HSChuyen).State = EntityState.Modified;
                        sc += db.SaveChanges();
                        //update dubao_sanphamn cho don hang chuyen phi
                        TH_DUBAO_SANPHAM THDBSPChuyen = db.TH_DUBAO_SANPHAM.FirstOrDefault(k => k.J_TH_DUBAO == A_DuBao_XepLopChuyen);
                        THDBSPChuyen.SOLUONG         = THDBSPChuyen.SOLUONG - (decimal)model1.SOBUOI;
                        THDBSPChuyen.THANHTIEN       = THDBSPChuyen.THANHTIEN - model1.TONGTIEN_DH;
                        db.Entry(THDBSPChuyen).State = EntityState.Modified;
                        sc += db.SaveChanges();
                        //update vao du bao xep lop cua hoc sinh nhan
                        TH_DUBAO HSNhan = db.TH_DUBAO.FirstOrDefault(it => it.A_TH_DUBAO == A_DuBao_XepLopNhan);
                        HSNhan.NGAYTHANHTOAN   = HSNhan.J_KEHOACH != null?model1.NGAYTHANHTOAN:null;
                        HSNhan.SOBUOI          = HSNhan.SOBUOI + model.SOBUOI;
                        HSNhan.TONGTIEN_DH     = HSNhan.TONGTIEN_DH + model1.TONGTIEN_DH;
                        db.Entry(HSNhan).State = EntityState.Modified;
                        sc += db.SaveChanges();
                        TH_DUBAO_SANPHAM THDBSPNhan = db.TH_DUBAO_SANPHAM.FirstOrDefault(k => k.J_TH_DUBAO == A_DuBao_XepLopNhan);
                        THDBSPNhan.SOLUONG         = THDBSPNhan.SOLUONG + (decimal)model.SOBUOI;
                        THDBSPNhan.THANHTIEN       = THDBSPNhan.THANHTIEN + model1.TONGTIEN_DH;
                        db.Entry(THDBSPNhan).State = EntityState.Modified;
                        sc += db.SaveChanges();
                    }
                }
                return(Json(sc, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(0, JsonRequestBehavior.AllowGet));
            }
        }
        public JsonResult CapNhatDangKyChuyenLopCungTrungTam(
            int J_HOSOKHACHHANG,
            int?J_KEHOACH,
            DateTime?NGAYGIAOHANG,
            decimal?TONGTIEN_DH,
            int?SOBUOI,
            decimal?DONGIA,
            int?ID_BOPHAN,
            string GHICHU,
            int?J_SANPHAM,
            DateTime?NGAYDUKIENHOC,
            int?J_HOPDONG,
            string TK_EC,
            string TK_EC_LEADER,
            string TK_CM,
            string TK_CM_LEADER,
            string TK_GDTT,
            string TK_GDV,
            int?ID_TRUNGTAM_DI,
            int?ID_TRUNGTAM_DEN,
            int?A_DuBao
            )
        {
            int sc      = 0;
            var thdubao = new TH_DUBAO();

            thdubao.J_KEHOACH       = J_KEHOACH;
            thdubao.J_TH_HOPDONG    = J_HOPDONG;
            thdubao.SOBUOI          = SOBUOI;
            thdubao.NGAYLAM         = DateTime.Now;
            thdubao.NGAYGIAOHANG    = NGAYDUKIENHOC;
            thdubao.NGAYTHANHTOAN   = NGAYGIAOHANG != null ? NGAYGIAOHANG : null;
            thdubao.ID_LYDO_HV      = 101;
            thdubao.ID_LYDO_TD      = 241;
            thdubao.ID_DTTC         = FCVDataProvider.GetUserID(User.Identity.Name);
            thdubao.TK_EC           = TK_EC;
            thdubao.TK_EC_LEADER    = TK_EC_LEADER;
            thdubao.TK_CM           = TK_CM;
            thdubao.TK_CM_LEADER    = TK_CM_LEADER;
            thdubao.TK_GDTT         = TK_GDTT;
            thdubao.TK_GDV          = TK_GDV;
            thdubao.ID_TRUNGTAM_DI  = ID_TRUNGTAM_DI;
            thdubao.ID_TRUNGTAM_DEN = ID_TRUNGTAM_DEN;
            thdubao.J_HOSOKHACHHANG = J_HOSOKHACHHANG;
            thdubao.DULIEUNHOM      = true;
            thdubao.TONGTIEN_DH     = TONGTIEN_DH;
            thdubao.DONGIA          = DONGIA;
            thdubao.ID_BOPHAN       = ID_BOPHAN;
            thdubao.GHICHU          = !string.IsNullOrEmpty(GHICHU) ? GHICHU : "";
            thdubao.A_THUCHIEN      = A_DuBao;
            db.TH_DUBAO.Add(thdubao);
            sc += db.SaveChanges();
            if (sc > 0)
            {
                int model          = db.TH_DUBAO.OrderByDescending(x => x.A_TH_DUBAO).FirstOrDefault().A_TH_DUBAO;
                var thdubaosanpham = new TH_DUBAO_SANPHAM();
                thdubaosanpham.J_TH_DUBAO = model;
                thdubaosanpham.J_SANPHAM  = J_SANPHAM > 0 ? (int)J_SANPHAM : 0;
                thdubaosanpham.SOLUONG    = SOBUOI > 0 ? (int)SOBUOI : 0;
                thdubaosanpham.DONGIA     = DONGIA;
                thdubaosanpham.CHIETKHAU  = 0;
                thdubaosanpham.THANHTIEN  = TONGTIEN_DH;
                //thdubaosanpham.DATENOTE1 = NGAYDUKIENHOC != null ? NGAYDUKIENHOC : DateTime.Now;
                //thdubaosanpham.DATENOTE2 = NGAYGIAOHANG != null ? NGAYGIAOHANG : DateTime.Now;
                db.TH_DUBAO_SANPHAM.Add(thdubaosanpham);
                sc += db.SaveChanges();
                TH_DUBAO DUBAO = db.TH_DUBAO.FirstOrDefault(st => st.A_TH_DUBAO == A_DuBao);
                DUBAO.ID_TRANGTHAI    = 1;
                db.Entry(DUBAO).State = EntityState.Modified;
                sc += db.SaveChanges();
            }
            if (sc > 0)
            {
                return(Json(1, JsonRequestBehavior.AllowGet));
            }
            return(Json(0, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public ActionResult CapNhatBaoLuuKetQua(
            int A_THDUBAO,
            int J_HOSOKHACHHANG,
            int J_KEHOACH,
            DateTime?NGAYLAM,
            DateTime?DENNGAY,
            int SOBUOI,
            int TONGSOBUOIDABAOLUU,
            DateTime?NGAYHOCCUOI,
            int ID_LYDO_NT,
            int J_SANPHAM,
            int SOBUOIBAOLUU,
            string GHICHUDUBAO)
        {
            int sc     = 0;
            var model2 = db.TH_DUBAO.FirstOrDefault(x => x.A_TH_DUBAO == A_THDUBAO);

            if (DateTime.Compare((DateTime)model2.NGAYTHANHTOAN, (DateTime)NGAYLAM) <= 0)
            {
                return(Json("Ngày bảo lưu không được phép sau ngày học cuối", JsonRequestBehavior.AllowGet));
            }
            if (DateTime.Compare((DateTime)NGAYLAM, (DateTime)model2.NGAYGIAOHANG) <= 0)
            {
                return(Json("Ngày bảo lưu không được phép trước ngày học chính thức và ngày dự kiến học", JsonRequestBehavior.AllowGet));
            }
            if (model2.NGAY1 != null && (DateTime.Compare((DateTime)NGAYLAM, (DateTime)model2.NGAY1) <= 0))
            {
                return(Json("Ngày bảo lưu không được phép trong khoản thời gian bảo lưu trước đó", JsonRequestBehavior.AllowGet));
            }
            var thdubao = new TH_DUBAO();

            thdubao.GHICHU           = GHICHUDUBAO;
            thdubao.J_HOSOKHACHHANG  = J_HOSOKHACHHANG;
            thdubao.J_KEHOACH        = J_KEHOACH;
            thdubao.NGAYLAM          = DateTime.Now;
            thdubao.SOBUOI           = SOBUOI;
            thdubao.TONGSOBUOIBAOLUU = SOBUOIBAOLUU;
            thdubao.ID_DTTC          = FCVDataProvider.GetUserID(User.Identity.Name);
            thdubao.NGAYGIAOHANG     = NGAYLAM;
            thdubao.NGAYTHANHTOAN    = DENNGAY;
            thdubao.ID_LYDO_HV       = 98;
            thdubao.ID_LYDO_NT       = ID_LYDO_NT;
            db.TH_DUBAO.Add(thdubao);
            db.SaveChanges();

            var a_th_dubao     = db.TH_DUBAO.OrderByDescending(x => x.A_TH_DUBAO).FirstOrDefault().A_TH_DUBAO;
            var thdubaosanpham = new TH_DUBAO_SANPHAM();

            thdubaosanpham.J_TH_DUBAO = a_th_dubao;
            thdubaosanpham.J_SANPHAM  = J_SANPHAM == null ? 0 : J_SANPHAM;
            thdubaosanpham.SOLUONG    = SOBUOIBAOLUU;
            thdubaosanpham.DATENOTE   = model2.NGAYTHANHTOAN;
            db.TH_DUBAO_SANPHAM.Add(thdubaosanpham);
            db.SaveChanges();
            model2.TONGSOBUOIBAOLUU = (model2.TONGSOBUOIBAOLUU > 0? model2.TONGSOBUOIBAOLUU:0) + SOBUOIBAOLUU;
            model2.NGAYTHANHTOAN    = NGAYHOCCUOI;
            model2.NGAY1            = DENNGAY;
            sc += db.SaveChanges();
            if (sc > 0)
            {
                if (Request.Files.Count > 0)
                {
                    try
                    {
                        HttpPostedFileBase avtFileInbox = Request.Files[0];
                        if (avtFileInbox != null && avtFileInbox.ContentLength > 0)
                        {
                            try
                            {
                                var           fileName   = Path.GetFileName(avtFileInbox.FileName);
                                var           path       = Path.Combine(Server.MapPath("~/Content/upload"), fileName);
                                TH_DUBAO_FILE DuLieuFile = new TH_DUBAO_FILE()
                                {
                                    FILENAME   = fileName,
                                    J_TH_DUBAO = a_th_dubao,
                                    PATHFILE   = path,
                                };
                                db.Set <TH_DUBAO_FILE>().Add(DuLieuFile);
                                int kc = db.SaveChanges();
                                if (kc > 0)
                                {
                                    avtFileInbox.SaveAs(path);
                                }
                            }
                            catch { }
                        }
                    }
                    catch
                    {
                    }
                }
                return(Json(1, JsonRequestBehavior.AllowGet));
            }
            return(Json(0, JsonRequestBehavior.AllowGet));
        }
        public JsonResult SaveDuyetXepLop(int?A_THDUBAO, int?IDDuyet, string NoiDung)
        {
            int sc = 0;

            try
            {
                TH_DUYETTHUCHIEN New = new TH_DUYETTHUCHIEN()
                {
                    J_TH_DUBAO  = A_THDUBAO,
                    ID_DTTC     = clsFunctions.GetUserID(),
                    NGAYDUYET   = DateTime.Now,
                    ID_DUYET    = IDDuyet,
                    YKIENBOSUNG = NoiDung
                };
                db.Set <TH_DUYETTHUCHIEN>().Add(New);
                sc += db.SaveChanges();
                if (sc > 0)
                {
                    sc += db.Database.ExecuteSqlCommand("Update TH_DUBAO set ID_LYDO_TD = 242 where A_TH_DUBAO =" + A_THDUBAO);
                    TH_DUBAO model = db.TH_DUBAO.FirstOrDefault(it => it.A_TH_DUBAO == A_THDUBAO);
                    if (sc > 1 && IDDuyet == 1 && model != null)
                    {
                        TH_DUBAO Moi = new TH_DUBAO()
                        {
                            J_KEHOACH       = model.J_KEHOACH,
                            J_TH_HOPDONG    = model.J_TH_HOPDONG,
                            J_HOSOKHACHHANG = model.J_HOSOKHACHHANG,
                            SOBUOI          = model.SOBUOI,
                            NGAYLAM         = DateTime.Now,
                            NGAYGIAOHANG    = model.NGAYGIAOHANG,
                            NGAYTHANHTOAN   = model.NGAYTHANHTOAN,
                            ID_LYDO_HV      = 97,
                            ID_LYDO_TD      = 238,
                            SODONHANG       = "123",
                            ID_DTTC         = FCVDataProvider.GetUserID(User.Identity.Name),
                            TK_EC           = model.TK_EC,
                            TK_EC_LEADER    = model.TK_EC_LEADER,
                            TK_CM           = model.TK_CM,
                            TK_CM_LEADER    = model.TK_CM_LEADER,
                            TK_GDTT         = model.TK_GDTT,
                            TK_GDV          = model.TK_GDV,
                            ID_TRUNGTAM_DI  = model.ID_TRUNGTAM_DI,
                            ID_TRUNGTAM_DEN = model.ID_TRUNGTAM_DEN,
                            DULIEUNHOM      = true
                        };
                        db.Set <TH_DUBAO>().Add(Moi);
                        sc += db.SaveChanges();
                        if (sc > 2)
                        {
                            int th_dubao                = db.TH_DUBAO.OrderByDescending(x => x.A_TH_DUBAO).FirstOrDefault().A_TH_DUBAO;
                            TH_DUBAO_SANPHAM dbsp       = db.TH_DUBAO_SANPHAM.FirstOrDefault(it => it.J_TH_DUBAO == A_THDUBAO);
                            TH_DUBAO_SANPHAM newdubaosp = new TH_DUBAO_SANPHAM()
                            {
                                J_TH_DUBAO = th_dubao,
                                J_SANPHAM  = dbsp.J_SANPHAM,
                                SOLUONG    = dbsp.SOLUONG,
                                DONGIA     = dbsp.DONGIA,
                                THANHTIEN  = dbsp.DONGIA
                            };
                            db.Set <TH_DUBAO_SANPHAM>().Add(newdubaosp);
                            sc += db.SaveChanges();
                        }
                    }
                }
                return(Json(sc, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(0, JsonRequestBehavior.AllowGet));
            }
        }