コード例 #1
0
        public void addLichSuHoaDon(int HoaDonID, int thangHoaDon, int namHoaDon, String tenKH, String diaChi, String MST, String maKH, int TuyenKHID, String soHD,
                                    int chiSoCu, int ChiSoMoi, int TongTieuThu, double SH1, double SH1Price, double SH2, double SH2Price, double SH3, double SH3Price, double SH4, double SH4Price, double HC, double doubleHCPrice,
                                    double CC, double CCPrice, double SX, double SXPrice, double KD, double KDPrice, double DinhMuc, double Thue, double TienThueVAT, double TileBVMT,
                                    double BVMTPrice, double TongCong, String bangChu, String TTVoOng, String ThuNgan, int tuyen, int TTDoc, double chiSoCongDon, string ngayBatDau, string ngayKetThuc)
        {
            Lichsuhoadon history = new Lichsuhoadon();

            history.HoaDonID        = HoaDonID;
            history.ThangHoaDon     = thangHoaDon;
            history.NamHoaDon       = namHoaDon;
            history.TenKH           = tenKH;
            history.Diachi          = diaChi;
            history.MST             = MST == null ? "" : MST;
            history.TuyenKHID       = TuyenKHID;
            history.MaKH            = maKH;
            history.SoHopDong       = soHD;
            history.ChiSoCu         = chiSoCu;
            history.ChiSoMoi        = ChiSoMoi;
            history.SanLuongTieuThu = TongTieuThu;
            history.SH1             = SH1;
            history.SH1Price        = SH1Price;
            history.SH2             = SH2;
            history.SH2Price        = SH2Price;
            history.SH3             = SH3;
            history.SH3Price        = SH3Price;
            history.SH4             = SH4;
            history.SH4Price        = SH4Price;
            history.HC            = HC;
            history.HCPrice       = doubleHCPrice;
            history.CC            = CC;
            history.CCPrice       = CCPrice;
            history.SX            = SX;
            history.SXPrice       = SXPrice;
            history.KD            = KD;
            history.KDPrice       = KDPrice;
            history.TruocThue     = DinhMuc;
            history.ThueSuat      = Thue;
            history.ThueSuatPrice = TienThueVAT;
            history.TileBVMT      = TileBVMT;
            history.PhiBVMT       = BVMTPrice;
            history.TongCong      = TongCong;
            history.BangChu       = ConvertMoney.So_chu(TongCong);
            history.TTVoOng       = TTVoOng;
            history.TTThungan     = ThuNgan;
            history.TuyenKHID     = tuyen;
            history.TTDoc         = TTDoc;
            history.ChiSoCongDon  = chiSoCongDon;
            history.NgayBatDau    = ngayBatDau;
            history.NgayKetThuc   = ngayKetThuc;
            db.Lichsuhoadons.Add(history);
            SaveChanges();
        }
コード例 #2
0
ファイル: PrintController.cs プロジェクト: war-man/hddn
        private void updateFromReceiptToReceipt(int?quan, string tuyenID, int thangIn, int namIn, int fromReceipt, int toReceipt)
        {
            var    hoadons = getDanhSachHoaDonDuocIn(tuyenID, thangIn, namIn);
            int    soHoaDon = 1;
            double tongTienCongDon = 0;
            double truocThue = 0; double thueVAT = 0; double phiBVMT = 0; double soTienHoaDon = 0;
            String ttVoOng = qHHelper.getTTVoOng(quan);

            using (SqlConnection connection = new SqlConnection(connectionString))

                foreach (var hoadon in hoadons)
                {
                    truocThue = Math.Floor((hoadon.SH1 * hoadon.SH1Price) + (hoadon.SH2 * hoadon.SH2Price) + (hoadon.SH3 * hoadon.SH3Price) + (hoadon.SH4 * hoadon.SH4Price)
                                           + (hoadon.CC * hoadon.CCPrice) + (hoadon.HC * hoadon.HCPrice) + (hoadon.SX * hoadon.SXPrice) + (hoadon.KD * hoadon.KDPrice));
                    thueVAT      = Math.Round(truocThue * 0.05, 0);
                    phiBVMT      = Math.Round(truocThue * (hoadon.TileBVMT / 100), 0);
                    soTienHoaDon = truocThue + thueVAT + phiBVMT;
                    var tuyenKH = db.Tuyenkhachhangs.Find(hoadon.TuyenKHID);

                    using (SqlCommand command = new SqlCommand("", connection))
                    {
                        connection.Open();
                        command.CommandText = "Update Lichsuhoadon set TTVoOng=@ttVoOng, TTThungan = @TTThuNgan, TruocThue=@truocThue, ThueSuatPrice=@thueVAT, PhiBVMT=@phi, TongCong=@tong, BangChu=@chu, ChiSoCongDon=@chiSo " +
                                              "WHERE HoaDonID = @HoaDonID";

                        command.Parameters.AddWithValue("@TTThuNgan", hoadon.TTDoc + "/" + tuyenKH.Matuyen + " - " + soHoaDon);
                        if (soHoaDon >= fromReceipt && soHoaDon <= toReceipt)
                        {
                            tongTienCongDon += hoadon.TongCong;
                            command.Parameters.AddWithValue("@chiSo", tongTienCongDon);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("@chiSo", tongTienCongDon);
                        }
                        command.Parameters.AddWithValue("@truocThue", truocThue);
                        command.Parameters.AddWithValue("@HoaDonID", hoadon.HoaDonNuoc);
                        command.Parameters.AddWithValue("@thueVAT", thueVAT);
                        command.Parameters.AddWithValue("@phi", phiBVMT);
                        command.Parameters.AddWithValue("@tong", soTienHoaDon);
                        command.Parameters.AddWithValue("@chu", ConvertMoney.So_chu(soTienHoaDon));
                        command.Parameters.AddWithValue("@ttVoOng", ttVoOng);
                        command.ExecuteNonQuery();
                        connection.Close();
                    }
                    soHoaDon++;
                }
        }
コード例 #3
0
ファイル: PrintController.cs プロジェクト: war-man/hddn
        private void updateSelectedReceipt(int?quan, string tuyenID, int thangIn, int namIn, String[] hoaDons)
        {
            String ttVoOng = qHHelper.getTTVoOng(quan);
            int    soHoaDon = 1; double tongTienCongDon = 0;
            double truocThue = 0; double thueVAT = 0; double phiBVMT = 0; double soTienHoaDon = 0;

            using (SqlConnection connection = new SqlConnection(connectionString))

                foreach (var hoaDon in hoaDons)
                {
                    int          hoaDonID = Convert.ToInt32(hoaDon);
                    Lichsuhoadon hoadon   = db.Lichsuhoadons.FirstOrDefault(p => p.HoaDonID == hoaDonID);
                    if (hoadon != null)
                    {
                        tongTienCongDon += hoadon.TongCong.Value;
                        truocThue        = Math.Floor((hoadon.SH1.Value * hoadon.SH1Price.Value) + (hoadon.SH2.Value * hoadon.SH2Price.Value) + (hoadon.SH3.Value * hoadon.SH3Price.Value) + (hoadon.SH4.Value * hoadon.SH4Price.Value)
                                                      + (hoadon.CC.Value * hoadon.CCPrice.Value) + (hoadon.HC.Value * hoadon.HCPrice.Value) + (hoadon.SX.Value * hoadon.SXPrice.Value) + (hoadon.KD.Value * hoadon.KDPrice.Value));
                        thueVAT      = Math.Round(truocThue * 0.05, 0);
                        phiBVMT      = Math.Round(truocThue * (hoadon.TileBVMT.Value / 100), 0);
                        soTienHoaDon = truocThue + thueVAT + phiBVMT;
                        var tuyenKH = db.Tuyenkhachhangs.Find(hoadon.TuyenKHID);
                        using (SqlCommand command = new SqlCommand("", connection))
                        {
                            connection.Open();
                            command.CommandText = "Update Lichsuhoadon set TTVoOng = @ttVoOng, TTThungan = @TTThuNgan, TruocThue=@truocThue, ThueSuatPrice=@thueVAT, PhiBVMT=@phi, TongCong=@tong, BangChu=@chu, ChiSoCongDon=@chiSo " +
                                                  "WHERE HoaDonID = @HoaDonID";
                            command.Parameters.AddWithValue("@ttVoOng", ttVoOng);
                            command.Parameters.AddWithValue("@TTThuNgan", hoadon.TTDoc + "/" + tuyenKH.Matuyen + " - " + soHoaDon);
                            command.Parameters.AddWithValue("@truocThue", truocThue);
                            command.Parameters.AddWithValue("@thueVAT", thueVAT);
                            command.Parameters.AddWithValue("@phi", phiBVMT);
                            command.Parameters.AddWithValue("@tong", soTienHoaDon);
                            command.Parameters.AddWithValue("@chu", ConvertMoney.So_chu(soTienHoaDon));
                            command.Parameters.AddWithValue("@chiSo", tongTienCongDon);
                            command.Parameters.AddWithValue("@HoaDonID", hoaDonID);
                            command.ExecuteNonQuery();
                            connection.Close();
                        }
                        soHoaDon++;
                    }
                }
        }
コード例 #4
0
        public void updateLichSuHoaDon(int HoaDonID, int thangHoaDon, int namHoaDon, String tenKH, String diaChi, String MST, String maKH, int TuyenKHID, String soHD,
                                       int chiSoCu, int ChiSoMoi, int TongTieuThu, double SH1, double SH1Price, double SH2, double SH2Price, double SH3, double SH3Price, double SH4, double SH4Price, double HC, double HCPrice,
                                       double CC, double CCPrice, double SX, double SXPrice, double KD, double KDPrice, double DinhMuc, double Thue, double TienThueVAT, double TileBVMT,
                                       double BVMTPrice, double TongCong, String bangChu, String TTVoOng, String ThuNgan, int tuyen, int TTDoc, double chiSoCongDon, string ngayBatDau, string ngayKetThuc)
        {
            Lichsuhoadon lichSuHoaDon = db.Lichsuhoadons.FirstOrDefault(p => p.HoaDonID == HoaDonID);

            if (lichSuHoaDon != null)
            {
                lichSuHoaDon.HoaDonID        = HoaDonID;
                lichSuHoaDon.ThangHoaDon     = thangHoaDon;
                lichSuHoaDon.NamHoaDon       = namHoaDon;
                lichSuHoaDon.TenKH           = tenKH;
                lichSuHoaDon.Diachi          = diaChi;
                lichSuHoaDon.MST             = MST == null ? "" : MST;
                lichSuHoaDon.MaKH            = maKH;
                lichSuHoaDon.TuyenKHID       = TuyenKHID;
                lichSuHoaDon.SoHopDong       = soHD;
                lichSuHoaDon.ChiSoCu         = chiSoCu;
                lichSuHoaDon.ChiSoMoi        = ChiSoMoi;
                lichSuHoaDon.SanLuongTieuThu = TongTieuThu;
                lichSuHoaDon.SH1             = SH1;
                lichSuHoaDon.SH1Price        = SH1Price;
                lichSuHoaDon.SH2             = SH2;
                lichSuHoaDon.SH2Price        = SH2Price;
                lichSuHoaDon.SH3             = SH3;
                lichSuHoaDon.SH3Price        = SH3Price;
                lichSuHoaDon.SH4             = SH4;
                lichSuHoaDon.SH4Price        = SH4Price;
                lichSuHoaDon.HC              = HC;
                lichSuHoaDon.HCPrice         = HCPrice;
                lichSuHoaDon.CC              = CC;
                lichSuHoaDon.CCPrice         = CCPrice;
                lichSuHoaDon.SX              = SX;
                lichSuHoaDon.SXPrice         = SXPrice;
                lichSuHoaDon.KD              = KD;
                lichSuHoaDon.KDPrice         = KDPrice;
                lichSuHoaDon.TruocThue       = DinhMuc;
                lichSuHoaDon.ThueSuat        = Thue;
                lichSuHoaDon.ThueSuatPrice   = TienThueVAT;
                lichSuHoaDon.TileBVMT        = TileBVMT;
                lichSuHoaDon.PhiBVMT         = BVMTPrice;
                lichSuHoaDon.TongCong        = TongCong;
                lichSuHoaDon.BangChu         = ConvertMoney.So_chu(TongCong);
                lichSuHoaDon.TTVoOng         = TTVoOng;
                lichSuHoaDon.TTThungan       = ThuNgan;
                lichSuHoaDon.TuyenKHID       = tuyen;
                lichSuHoaDon.TTDoc           = TTDoc;
                lichSuHoaDon.ChiSoCongDon    = chiSoCongDon;
                lichSuHoaDon.NgayBatDau      = ngayBatDau;
                lichSuHoaDon.NgayKetThuc     = ngayKetThuc;
                db.Entry(lichSuHoaDon).State = EntityState.Modified;
                db.SaveChanges();
            }
            else
            {
                addLichSuHoaDon(HoaDonID, thangHoaDon, namHoaDon, tenKH, diaChi, MST, maKH, TuyenKHID, soHD,
                                chiSoCu, ChiSoMoi, TongTieuThu, SH1, SH1Price, SH2, SH2Price, SH3, SH3Price, SH4, SH4Price, HC, HCPrice,
                                CC, CCPrice, SX, SXPrice, KD, KDPrice, DinhMuc, Thue, TienThueVAT, TileBVMT,
                                BVMTPrice, TongCong, bangChu, TTVoOng, ThuNgan, tuyen, TTDoc, chiSoCongDon, ngayBatDau, ngayKetThuc);
            }
        }