Пример #1
0
        public IHttpActionResult PutBH_DON_BAN_HANG(string masobh, DonBanHang bH_DON_BAN_HANG)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (masobh != bH_DON_BAN_HANG.MA_SO_BH)
            {
                return(BadRequest());
            }

            var query = db.BH_DON_BAN_HANG.Where(x => x.MA_SO_BH == masobh).FirstOrDefault();

            if (query != null)
            {
                query.NGAY_BH               = xlnt.Xulydatetime(bH_DON_BAN_HANG.NGAY_BH.ToString());
                query.MA_KHACH_HANG         = bH_DON_BAN_HANG.MA_KHACH_HANG;
                query.TEN_LIEN_HE           = bH_DON_BAN_HANG.TEN_LIEN_HE;
                query.HINH_THUC_THANH_TOAN  = bH_DON_BAN_HANG.HINH_THUC_THANH_TOAN;
                query.TONG_TIEN_HANG        = bH_DON_BAN_HANG.TONG_TIEN_HANG;
                query.SO_TIEN_VIET_BANG_CHU = bH_DON_BAN_HANG.SO_TIEN_VIET_BANG_CHU;
                query.NGAY_GIAO_HANG        = xlnt.Xulydatetime(bH_DON_BAN_HANG.NGAY_GIAO_HANG.ToString());
                query.DIA_DIEM_GIAO_HANG    = bH_DON_BAN_HANG.DIA_DIEM_GIAO_HANG;
                query.DA_XUAT_KHO           = bH_DON_BAN_HANG.DA_XUAT_KHO;
                query.TONG_TIEN_THANH_TOAN  = bH_DON_BAN_HANG.TONG_TIEN_THANH_TOAN;
                query.TONG_TIEN_THUE_GTGT   = bH_DON_BAN_HANG.TONG_TIEN_THUE_GTGT;
                query.DA_LAP_HOA_DON        = bH_DON_BAN_HANG.DA_LAP_HOA_DON;
            }

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BH_DON_BAN_HANGExists(masobh))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostKT_SO_NHAT_KY_CHUNG(DonBanHang kT_SO_NHAT_KY_CHUNG)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            foreach (var item in kT_SO_NHAT_KY_CHUNG.ChiTietBH)
            {
                KT_SO_NHAT_KY_CHUNG chitiet1 = new KT_SO_NHAT_KY_CHUNG();
                chitiet1.NGAY_HACH_TOAN      = xlnt.Xulydatetime(kT_SO_NHAT_KY_CHUNG.NGAY_BH);
                chitiet1.NGAY_CHUNG_TU       = xlnt.Xulydatetime(kT_SO_NHAT_KY_CHUNG.NGAY_BH);
                chitiet1.SO_CHUNG_TU         = kT_SO_NHAT_KY_CHUNG.MA_SO_BH;
                chitiet1.DOI_TUONG           = kT_SO_NHAT_KY_CHUNG.MA_KHACH_HANG;
                chitiet1.TRUC_THUOC          = kT_SO_NHAT_KY_CHUNG.TRUC_THUOC;
                chitiet1.DIEN_GIAI_CHUNG     = kT_SO_NHAT_KY_CHUNG.DIEN_GIAI_CHUNG;
                chitiet1.DIEN_GIAI_CHI_TIET  = item.MA_HANG;
                chitiet1.TAI_KHOAN_HACH_TOAN = item.TK_NO;
                chitiet1.TAI_KHOAN_DOI_UNG   = item.TK_CO;
                chitiet1.PHAT_SINH_NO        = Convert.ToDecimal(item.TIEN_THANH_TOAN);
                chitiet1.PHAT_SINH_CO        = 0;
                db.KT_SO_NHAT_KY_CHUNG.Add(chitiet1);
                KT_SO_NHAT_KY_CHUNG chitiet2 = new KT_SO_NHAT_KY_CHUNG();
                chitiet2.NGAY_HACH_TOAN      = xlnt.Xulydatetime(kT_SO_NHAT_KY_CHUNG.NGAY_BH);
                chitiet2.NGAY_CHUNG_TU       = xlnt.Xulydatetime(kT_SO_NHAT_KY_CHUNG.NGAY_BH);
                chitiet2.SO_CHUNG_TU         = kT_SO_NHAT_KY_CHUNG.MA_SO_BH;
                chitiet2.DOI_TUONG           = kT_SO_NHAT_KY_CHUNG.MA_KHACH_HANG;
                chitiet2.TRUC_THUOC          = kT_SO_NHAT_KY_CHUNG.TRUC_THUOC;
                chitiet2.DIEN_GIAI_CHUNG     = kT_SO_NHAT_KY_CHUNG.DIEN_GIAI_CHUNG;
                chitiet2.DIEN_GIAI_CHI_TIET  = item.MA_HANG;
                chitiet2.TAI_KHOAN_HACH_TOAN = item.TK_CO;
                chitiet2.TAI_KHOAN_DOI_UNG   = item.TK_NO;
                chitiet2.PHAT_SINH_NO        = 0;
                chitiet2.PHAT_SINH_CO        = Convert.ToDecimal(item.TIEN_THANH_TOAN);
                db.KT_SO_NHAT_KY_CHUNG.Add(chitiet2);
                if (item.TK_THUE != null)
                {
                    KT_SO_NHAT_KY_CHUNG chitiet3 = new KT_SO_NHAT_KY_CHUNG();
                    chitiet3.NGAY_HACH_TOAN      = xlnt.Xulydatetime(kT_SO_NHAT_KY_CHUNG.NGAY_BH);
                    chitiet3.NGAY_CHUNG_TU       = xlnt.Xulydatetime(kT_SO_NHAT_KY_CHUNG.NGAY_BH);
                    chitiet3.SO_CHUNG_TU         = kT_SO_NHAT_KY_CHUNG.MA_SO_BH;
                    chitiet3.DOI_TUONG           = kT_SO_NHAT_KY_CHUNG.MA_KHACH_HANG;
                    chitiet3.TRUC_THUOC          = kT_SO_NHAT_KY_CHUNG.TRUC_THUOC;
                    chitiet3.DIEN_GIAI_CHUNG     = kT_SO_NHAT_KY_CHUNG.DIEN_GIAI_CHUNG;
                    chitiet3.DIEN_GIAI_CHI_TIET  = item.DIEN_GIAI_THUE;
                    chitiet3.TAI_KHOAN_HACH_TOAN = item.TK_NO;
                    chitiet3.TAI_KHOAN_DOI_UNG   = item.TK_THUE;
                    chitiet3.PHAT_SINH_NO        = Convert.ToDecimal(item.TIEN_THUE_GTGT);
                    chitiet3.PHAT_SINH_CO        = 0;
                    db.KT_SO_NHAT_KY_CHUNG.Add(chitiet3);
                    KT_SO_NHAT_KY_CHUNG chitiet4 = new KT_SO_NHAT_KY_CHUNG();
                    chitiet4.NGAY_HACH_TOAN      = xlnt.Xulydatetime(kT_SO_NHAT_KY_CHUNG.NGAY_BH);
                    chitiet4.NGAY_CHUNG_TU       = xlnt.Xulydatetime(kT_SO_NHAT_KY_CHUNG.NGAY_BH);
                    chitiet4.SO_CHUNG_TU         = kT_SO_NHAT_KY_CHUNG.MA_SO_BH;
                    chitiet4.DOI_TUONG           = kT_SO_NHAT_KY_CHUNG.MA_KHACH_HANG;
                    chitiet4.TRUC_THUOC          = kT_SO_NHAT_KY_CHUNG.TRUC_THUOC;
                    chitiet4.DIEN_GIAI_CHUNG     = kT_SO_NHAT_KY_CHUNG.DIEN_GIAI_CHUNG;
                    chitiet4.DIEN_GIAI_CHI_TIET  = item.DIEN_GIAI_THUE;
                    chitiet4.TAI_KHOAN_HACH_TOAN = item.TK_THUE;
                    chitiet4.TAI_KHOAN_DOI_UNG   = item.TK_NO;
                    chitiet4.PHAT_SINH_NO        = 0;
                    chitiet4.PHAT_SINH_CO        = Convert.ToDecimal(item.TIEN_THUE_GTGT);
                    db.KT_SO_NHAT_KY_CHUNG.Add(chitiet4);
                    db.SaveChanges();
                }
                db.SaveChanges();
            }

            return(Ok("Hoàn Thành"));
        }