Beispiel #1
0
        void RutKH()
        {
            using (var db = new MoneyEntity())
            {
                //   var stk = db.CIMASTs.Where(x => x.ACCTNO == DanhSachSTK.maSTK).Single();
                int daynow = thisIsMagic(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                int day    = thisIsMagic(stk.FRDATE.Year, stk.FRDATE.Month, stk.FRDATE.Day);
                int k      = daynow - day;
                if (k >= (stk.TERM * 30))
                {
                    CITRAN rutien = new CITRAN();
                    rutien.ACCTNO    = stk.ACCTNO;
                    rutien.BKDATE    = DateTime.Now;
                    rutien.SoTienRut = double.Parse(txbSoTien.Text);
                    rutien.TienLai   = (stk.Balance * (stk.TERM * 30) * (stk.RATE / 100)) / 12 + (stk.Balance * (k - (stk.TERM * 30)) * (stk.NPTERM / 100) / 365);
                    rutien.DemNgay   = k;


                    db.cITRANs.Add(rutien);
                    stk.Balance = stk.Balance - sotien;
                    db.SaveChanges();

                    for (int intCounter = App.Current.Windows.Count - 1; intCounter > -1; intCounter--)
                    {
                        if (App.Current.Windows[intCounter].Name != "Main_Window_wind")
                        {
                            App.Current.Windows[intCounter].Visibility = System.Windows.Visibility.Hidden;
                        }
                    }
                    DanhSachSTK ds = new DanhSachSTK();
                    ds.ShowDialog();
                }


                else
                {
                    if (stk.DEPOSITAMT == stk.Balance)
                    {
                        dem = k;
                        Chu_Y chuy = new Chu_Y();
                        chuy.ShowDialog();
                    }

                    else
                    {
                        var lst    = db.cITRANs.Where(x => x.ACCTNO == stk.ACCTNO).OrderByDescending(c => c.BKDATE).Select(c => c.BKDATE).ToList();
                        var asd    = lst[0]; // lấy ra ngày cuối cùng rút tiền
                        int demlai = daynow - thisIsMagic(asd.Year, asd.Month, asd.Day);
                        dem = demlai;
                        Chu_Y chuy = new Chu_Y();
                        chuy.ShowDialog();
                    }
                }
            }
        }
Beispiel #2
0
        private void btnTatToan_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Bạn có muốn tất toán tài khoản", "Thông báo", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                using (var db = new MoneyEntity())
                {
                    var stk    = db.CIMASTs.Where(x => x.ACCTNO == DanhSachSTK.maSTK).Single();
                    int ngay   = stk.TERM * 30;
                    int daynow = RutTien.thisIsMagic(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                    int day    = RutTien.thisIsMagic(stk.FRDATE.Year, stk.FRDATE.Month, stk.FRDATE.Day);
                    int k      = daynow - day;
                    if (DateTime.Now >= stk.FRDATE.AddDays(ngay))
                    {
                        CITRAN ci = new CITRAN()
                        {
                            ACCTNO    = stk.ACCTNO,
                            BKDATE    = DateTime.Now,
                            DemNgay   = k,
                            TienLai   = (stk.Balance * (stk.TERM * 30) * (stk.RATE / 100)) / 12 + (stk.Balance * (k - (stk.TERM * 30)) * (stk.NPTERM / 100) / 365),
                            SoTienRut = stk.Balance,
                        };
                        db.cITRANs.Add(ci);
                        stk.Balance = 0;
                        stk.STT     = "Tất toán";
                        db.SaveChanges();

                        MessageBox.Show("Tất toán thành công", "Thông báo", MessageBoxButton.OK);
                        for (int intCounter = App.Current.Windows.Count - 1; intCounter > -1; intCounter--)
                        {
                            if (App.Current.Windows[intCounter].Name != "Main_Window_wind")
                            {
                                App.Current.Windows[intCounter].Visibility = System.Windows.Visibility.Hidden;
                            }
                        }
                        DanhSachSTK dn = new DanhSachSTK();
                        dn.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Chưa đến hạn tất toán", "Error", MessageBoxButton.OK);
                    }
                }
            }
        }
Beispiel #3
0
        void RutKhongKH()
        {
            using (var db = new MoneyEntity())
            {
                //  var stk = db.CIMASTs.Where(x => x.ACCTNO == DanhSachSTK.maSTK).Single();
                int daynow = thisIsMagic(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                int day    = thisIsMagic(stk.FRDATE.Year, stk.FRDATE.Month, stk.FRDATE.Day);
                int k      = daynow - day;
                if (stk.DEPOSITAMT == stk.Balance)
                {
                    CITRAN rutien = new CITRAN()
                    {
                        ACCTNO    = stk.ACCTNO,
                        BKDATE    = DateTime.Now,
                        SoTienRut = double.Parse(txbSoTien.Text),
                        TienLai   = (stk.Balance * k * (stk.RATE / 100)) / 365,
                        DemNgay   = k
                    };
                    db.cITRANs.Add(rutien);
                    stk.Balance = stk.Balance - sotien;
                    db.SaveChanges();
                }

                else
                {
                    stk.Balance = stk.Balance - sotien;
                    db.SaveChanges();
                    var    lst    = db.cITRANs.Where(x => x.ACCTNO == stk.ACCTNO).OrderByDescending(c => c.BKDATE).Select(c => c.BKDATE).ToList();
                    var    asd    = lst[0];                                             // lấy ra ngày cuối cùng rút tiền
                    int    demlai = daynow - thisIsMagic(asd.Year, asd.Month, asd.Day); // đếm lại ngày tính lãi
                    CITRAN rutien = new CITRAN()
                    {
                        ACCTNO    = stk.ACCTNO,
                        BKDATE    = DateTime.Now,
                        SoTienRut = double.Parse(txbSoTien.Text),
                        TienLai   = (stk.Balance * demlai * (stk.RATE / 100)) / 365,
                        DemNgay   = demlai
                    };
                    db.cITRANs.Add(rutien);
                    db.SaveChanges();
                }
            }
        }