コード例 #1
0
        public JsonResult Delete(int id)
        {
            HocPhi sinhVien = db.HocPhis.Find(id);

            db.HocPhis.Remove(sinhVien);
            return(Json(db.SaveChanges()));
        }
コード例 #2
0
        public IActionResult QuanLyHocPhi(IFormCollection collection)
        {
            if (!IsLogin())
            {
                return(null);
            }


            int code = Convert.ToInt16(collection["code"]);

            if (code == 1)
            {
                var result = csdl.HocPhis.ToList();
                return(Json(result));
            }
            else if (code == 2)
            {
                var result = csdl.HocSinhs.ToList();
                return(Json(result));
            }
            else if (code == 3)
            {
                var hocPhiId = Convert.ToInt16(collection["hocPhiId"]);
                var result   = csdl.HocPhis.First(h => h.HocPhiId == hocPhiId);
                return(Json(result));
            }
            else if (code == 4)
            {
                var hocSinhId = Convert.ToInt16(collection["hocSinhId"]);
                var result    = csdl.HocPhis.Where(h => h.HocSinhId == hocSinhId).ToList();
                return(Json(result));
            }
            else if (code == 5)
            {
                var hocSinhId     = Convert.ToInt16(collection["hocSinhId"]);
                var soTien        = Convert.ToInt16(collection["soTien"]);
                var ngayThanhToan = DateTime.Parse(collection["ngayThanhToan"]);
                var ngayHetHan    = DateTime.Parse(collection["ngayHetHan"]);

                HocPhi newHocPhi = new HocPhi()
                {
                    HocSinhId     = hocSinhId,
                    SoTien        = soTien,
                    NgayThanhToan = ngayThanhToan,
                    NgayHetHan    = ngayHetHan
                };

                csdl.HocPhis.Add(newHocPhi);
                csdl.SaveChanges();
                return(Json(newHocPhi.HocPhiId));
            }
            else if (code == 6)
            {
                var hocPhiId = Convert.ToInt16(collection["hocPhiId"]);
                csdl.HocPhis.Remove(csdl.HocPhis.First(h => h.HocPhiId == hocPhiId));
                csdl.SaveChanges();
                return(Json("Deleted"));
            }
            return(null);
        }
コード例 #3
0
 public void FillData(HocPhi hp, int month)
 {
     lblAn.Text = lblDonGia.Text = lblNgayH.Text = lblNgayN.Text = lblDien.Text = lblHoc.Text = lblNuoc.Text = lblTaiLieu.Text = lblTTBi.Text = lblVeSinh.Text = lblTong.Text = lblTien.Text = "";
     if (month == DateTime.Now.Month)
     {
         lblAn.Text        = FormatIntToString(hp.TongAn);
         lblDonGia.Text    = FormatIntToString(hp.TienAn);
         lblNgayH.Text     = hp.SoNgayHoc + " ngày";
         lblNgayN.Text     = 0 + " ngày";
         lblDien.Text      = FormatIntToString(hp.TienDien);
         lblHoc.Text       = FormatIntToString(hp.TienHoc);
         lblNuoc.Text      = FormatIntToString(hp.TienNuoc);
         lblTaiLieu.Text   = FormatIntToString(hp.TienTaiLieu);
         lblTTBi.Text      = FormatIntToString(hp.TienTrangThietBi);
         lblVeSinh.Text    = FormatIntToString(hp.TienVeSinh);
         lblTong.Text      = FormatIntToString(hp.TongTien - App.StudentSeclect.Tien);
         lblTien.Text      = FormatIntToString(App.StudentSeclect.Tien);
         sloTien.IsVisible = true;
     }
     else
     {
         lblAn.Text        = FormatIntToString(hp.TongAn - (hp.TienAn * NghiP));
         lblDonGia.Text    = FormatIntToString(hp.TienAn);
         lblNgayH.Text     = hp.SoNgayHoc + " ngày";
         lblNgayN.Text     = NghiP + " ngày";
         lblDien.Text      = FormatIntToString(hp.TienDien);
         lblHoc.Text       = FormatIntToString(hp.TienHoc);
         lblNuoc.Text      = FormatIntToString(hp.TienNuoc);
         lblTaiLieu.Text   = FormatIntToString(hp.TienTaiLieu);
         lblTTBi.Text      = FormatIntToString(hp.TienTrangThietBi);
         lblVeSinh.Text    = FormatIntToString(hp.TienVeSinh);
         lblTong.Text      = FormatIntToString(hp.TongTien - (hp.TienAn * NghiP));
         sloTien.IsVisible = false;
     }
 }
コード例 #4
0
ファイル: HocPhiDaoImpl.cs プロジェクト: hunghe43/QLMN_WPF
        //public DataSet GetListHocPhi()
        //{
        //    using (conn )
        //    {
        //        if (conn.State == ConnectionState.Closed)
        //            conn.Open();
        //        SqlCommand command = conn.CreateCommand();
        //        command.CommandType = CommandType.StoredProcedure;
        //        command.CommandText = "GetListHocPhi";
        //        SqlDataAdapter adapter = new SqlDataAdapter(command);
        //        DataSet dataset = new DataSet();
        //        adapter.Fill(dataset);

        //        return dataset;
        //    }
        //}


        public List <HocPhi> GetListHocPhi()
        {
            List <HocPhi> list = new List <HocPhi>();

            using (conn = new SqlConnection(connString))
            {
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                SqlCommand command = conn.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "GetListHocPhi";
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataTable      dt      = new DataTable();
                adapter.Fill(dt);
                HocPhi hp;
                foreach (DataRow dr in dt.Rows)
                {
                    hp            = new HocPhi();
                    hp.MaHocPhi   = Convert.ToString(dr["MaHocPhi"]);
                    hp.TenhocPhi  = Convert.ToString(dr["TenhocPhi"]);
                    hp.ChiPhi     = Convert.ToInt32(dr["ChiPhi"]);
                    hp.LoaiHocPhi = Convert.ToString(dr["LoaiHocPhi"]);
                    list.Add(hp);
                }
            }
            return(list);
        }
コード例 #5
0
ファイル: HocPhiDaoImpl.cs プロジェクト: hunghe43/QLMN_WPF
 /// <summary>
 /// add
 /// </summary>
 /// <param name="hocphi"></param>
 public void AddHocPhi(HocPhi hocphi)
 {
     hocphi.MaHocPhi = AutoIdHocPhi();
     using (conn = new SqlConnection(connString))
     {
         if (conn.State != ConnectionState.Open)
         {
             conn.Open();
         }
         SqlCommand command = conn.CreateCommand();
         command.CommandType = CommandType.StoredProcedure;
         command.CommandText = "InsertUpdateHocPhi";
         command.Parameters.Add("@MaHocPhi", SqlDbType.VarChar, 20).Value   = hocphi.MaHocPhi;
         command.Parameters.Add("@TenHocPhi", SqlDbType.NVarChar, 50).Value = hocphi.TenhocPhi;
         command.Parameters.Add("@ChiPhi", SqlDbType.Decimal).Value         = hocphi.ChiPhi;
         command.Parameters.Add("@GhiChu", SqlDbType.NVarChar, 100).Value   = hocphi.GhiChu;
         command.Parameters.Add("@LoaiHocPhi", SqlDbType.VarChar, 20).Value = hocphi.LoaiHocPhi;
         command.Parameters.Add("@Action", SqlDbType.VarChar, 10).Value     = "Insert";
         try
         {
             command.ExecuteNonQuery();
         }
         catch (Exception ex)
         {
             throw ex;
         }
         finally
         {
             command.Dispose();
             conn.Dispose();
         }
     }
 }
コード例 #6
0
        public override async Task <ResponseEntity> InsertAsync(KhachHangViewModel modelVm)
        {
            try
            {
                KhachHang entity = _mapper.Map <KhachHang>(modelVm);
                entity = await _khachHangRepository.InsertAsync(entity);

                HocPhiViewModel hocPhiVm = new HocPhiViewModel();
                if (modelVm.MaTrangThaiKH == 2)
                {
                    hocPhiVm      = modelVm.HocPhi;
                    hocPhiVm.MaKH = entity.Id;

                    HocPhi hocPhi = _mapper.Map <HocPhi>(hocPhiVm);
                    await _hocPhiRepository.InsertAsync(hocPhi);
                }

                modelVm        = _mapper.Map <KhachHangViewModel>(entity);
                modelVm.HocPhi = hocPhiVm;
                return(new ResponseEntity(StatusCodeConstants.CREATED, modelVm, MessageConstants.INSERT_SUCCESS));
            }
            catch (Exception ex)
            {
                return(new ResponseEntity(StatusCodeConstants.ERROR_SERVER, ex.Message));
            }
        }
コード例 #7
0
        private void btnTraCuu_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            HocPhi tthp = new HocPhi();

            dgvTraCuu.DataSource = tthp.getjoin_hv(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword(), cbxMaHV.Text);
            this.Cursor          = Cursors.Arrow;
        }
コード例 #8
0
 public ActionResult Edit(HocPhi obj)
 {
     if (obj.IDHocPhi > 0)
     {
         db.Entry(obj).State = EntityState.Modified;
     }
     else
     {
         db.HocPhis.Add(obj);
     }
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
コード例 #9
0
        public ActionResult Edit(int?id)
        {
            HocPhi obj = new HocPhi();

            if (id.HasValue)
            {
                obj = db.HocPhis.Find(id);
            }
            if (obj == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IDNamHocs   = db.NamHocs.Where(q => q.Active != false).CreateSelectList(q => q.IDNamHoc, q => q.TenNamHoc, obj.IDInfoKyHoc);
            ViewBag.IDKyHocs    = db.KyHocs.Where(q => q.Active != false).CreateSelectList(q => q.IDKyHoc, q => q.TenHocKy, obj.IDInfoKyHoc);
            ViewBag.IDSinhViens = db.SinhViens.Where(q => q.Active != false).CreateSelectList(q => q.IDSinhVien, q => q.FullName, obj.IDSinhVien);
            return(View(obj));
        }
コード例 #10
0
        private void btnApDungHocPhi_Click(object sender, EventArgs e)
        {
            if (dgvTre.SelectedRows.Count == 0)
            {
                MessageBox.Show("Phải chọn ít nhất một trẻ để áp dụng học phí.");
                return;
            }
            try
            {
                for (int i = 0; i < dgvTre.SelectedRows.Count; i++)
                {
                    if (TreBLL.KiemTraTreThoiHoc(dgvTre.SelectedRows[i].Cells["MaTre"].Value.ToString(),
                                                 KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString())))
                    {
                        message += dgvTre.SelectedRows[i].Cells["HoTenTre"].Value.ToString() + "\n";
                        continue;
                    }
                    HocPhi hocPhi = new HocPhi();
                    hocPhi.MaHocPhi         = dgvTre.SelectedRows[i].Cells["MaHocPhi"].Value.ToString();
                    hocPhi.MaTre            = dgvTre.SelectedRows[i].Cells["MaTre"].Value.ToString();
                    hocPhi.Thang            = int.Parse(dgvTre.SelectedRows[i].Cells["Thang"].Value.ToString());
                    hocPhi.Nam              = int.Parse(dgvTre.SelectedRows[i].Cells["Nam"].Value.ToString());
                    hocPhi.HocPhiThangNay   = HocPhiBLL.TinhHocPhiThangNay(hocPhi, listChiTietHocPhi);
                    hocPhi.TienNoThangTruoc = HocPhiBLL.LayTienNoHocPhiThangTruoc(hocPhi);
                    hocPhi.TongTienHocPhi   = hocPhi.HocPhiThangNay + hocPhi.TienNoThangTruoc;
                    hocPhi.SoTienDaDong     = decimal.Parse(dgvTre.SelectedRows[i].Cells["SoTienDaDong"].Value.ToString());
                    hocPhi.SoTienConNo      = hocPhi.TongTienHocPhi - hocPhi.SoTienDaDong;

                    HocPhiBLL.CapNhatHocPhi(hocPhi, listChiTietHocPhi);
                }
                if (message == "")
                {
                    MessageBox.Show("Áp dụng học phí thanh công!");
                }
                else
                {
                    MessageBox.Show("Trẻ: \n" + message + "đã thôi học nên không được xét học phí.");
                    message = "";
                }
            } catch (Exception ex)
            {
                MessageBox.Show("Đã có lỗi xảy ra.");
            }

            RefreshView();
        }
コード例 #11
0
        /// <summary>
        /// Hàm thực hiện thêm mới học phí
        /// </summary>
        /// <param name="parameter"></param>
        private void OnAddHocPhi(object parameter)
        {
            var values = (object[])parameter;
            var window = (Window)values[0];
            var stack  = (StackPanel)values[1];

            try
            {
                HocPhiDaoImpl impl   = new HocPhiDaoImpl();
                HocPhi        hocphi = new HocPhi();
                foreach (var child in stack.Children)
                {
                    string name = null;
                    if (child is FrameworkElement)
                    {
                        name = (child as FrameworkElement).Name.ToString();

                        switch (name)
                        {
                        case "txtTenHocPhi":
                            hocphi.TenhocPhi = (child as TextBox).Text;
                            break;

                        case "txtChiPhi":
                            hocphi.ChiPhi = (int)(child as NumericUpDown).Value.GetValueOrDefault();;
                            break;

                        case "txtGhiChu":
                            hocphi.GhiChu = (child as TextBox).Text;
                            break;

                        case "cbxLoaiHocPhi":
                            hocphi.LoaiHocPhi = (child as ComboBox).SelectedValue.ToString();
                            break;
                        }
                    }
                }
                impl.AddHocPhi(hocphi);
                window.DataContext = new MetadataHocPhiViewModel();
                MessageBox.Show("Susscess!");
            }
            catch
            {
                MessageBox.Show("Fail!");
            }
        }
コード例 #12
0
ファイル: HocPhiDAL.cs プロジェクト: vanhongha/QLNT_OODA
        public static void KhoiTaoHocPhi(HocPhi hocPhi)
        {
            DataAccessHelper.GetInstance().Open();
            SqlCommand cmd = DataAccessHelper.GetInstance().Command("KhoiTaoHocPhi");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@MaHocPhi", hocPhi.MaHocPhi);
            cmd.Parameters.AddWithValue("@MaTre", hocPhi.MaTre);
            cmd.Parameters.AddWithValue("@Thang", hocPhi.Thang);
            cmd.Parameters.AddWithValue("@Nam", hocPhi.Nam);

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            DataAccessHelper.GetInstance().SetDataTable(new DataTable());
            da.Fill(DataAccessHelper.GetInstance().GetDataTable());
            DataAccessHelper.GetInstance().Close();
        }
コード例 #13
0
        private void Load_DL()
        {
            //load combobox mã học viên
            HocVien   hv    = new HocVien();
            DataTable tb_hv = new DataTable();

            tb_hv = hv.getAll(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword());
            cbxMaHV.DataSource    = tb_hv;
            cbxMaHV.ValueMember   = tb_hv.Columns[0].ToString();
            cbxMaHV.DisplayMember = tb_hv.Columns[0].ToString();



            //Load lên datagridview
            HocPhi hp = new HocPhi();

            dataGridView1.DataSource = hp.getjoin(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword());
        }
コード例 #14
0
 private void OnDeleteHocPhi(object parameter)
 {
     try
     {
         var           values     = (object[])parameter;
         var           window     = (Window)values[0];
         var           listhocphi = (ListBox)values[1];
         HocPhi        hocphi     = listhocphi.SelectedItem as HocPhi;
         HocPhiDaoImpl impl       = new HocPhiDaoImpl();
         impl.DeleteHocPhi(hocphi.MaHocPhi);
         window.DataContext = new MetadataHocPhiViewModel();
         MessageBox.Show("Susscess!");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
コード例 #15
0
ファイル: HocPhiDAL.cs プロジェクト: vanhongha/QLNT_OODA
        public static void CapNhatHocPhi(HocPhi hocPhi)
        {
            DataAccessHelper.GetInstance().Open();
            SqlCommand cmd = DataAccessHelper.GetInstance().Command("CapNhatHocPhi");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@MaHocPhi", hocPhi.MaHocPhi);
            cmd.Parameters.AddWithValue("@HocPhiThangNay", hocPhi.HocPhiThangNay);
            cmd.Parameters.AddWithValue("@TienNoThangTruoc", hocPhi.TienNoThangTruoc);
            cmd.Parameters.AddWithValue("@TongTienHocPhi", hocPhi.TongTienHocPhi);
            cmd.Parameters.AddWithValue("@SoTienDaDong", hocPhi.SoTienDaDong);
            cmd.Parameters.AddWithValue("@SoTienConNo", hocPhi.SoTienConNo);

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            DataAccessHelper.GetInstance().SetDataTable(new DataTable());
            da.Fill(DataAccessHelper.GetInstance().GetDataTable());
            DataAccessHelper.GetInstance().Close();
        }
コード例 #16
0
        public ActionResult Index(List <KQHT> lst)
        {
            lst.ForEach(q =>
            {
                if (q.IDKQHT > 0)
                {
                    if (q.IDLopDT > 0)
                    {
                        db.Entry(q).State = System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        db.KQHTs.Remove(q);
                    }
                }
                else if (q.IDLopDT > 0)
                {
                    db.KQHTs.Add(q);
                }
            });
            db.SaveChanges();

            var info   = db.InfoKyHocs.FirstOrDefault(q => q.Status == "OPEN");
            var hocphi = db.HocPhis.FirstOrDefault(q => q.IDSinhVien == Account.IDSinhVien && q.InfoKyHoc.Status == "OPEN");

            if (hocphi == null)
            {
                hocphi = new HocPhi()
                {
                    IDSinhVien  = Account.IDSinhVien,
                    IDInfoKyHoc = info.IDInfoKyHoc
                }
            }
            ;
            hocphi.Paid   = 0;
            hocphi.Total  = db.KQHTs.Where(q => q.IDSinhVien == Account.IDSinhVien && q.LopDT.IDInfoKyHoc == info.IDInfoKyHoc).Sum(q => q.LopDT.CTDT.MonHoc.SoTC * info.PhiTC);
            hocphi.Status = "0";
            db.HocPhis.Add(hocphi);

            db.SaveChanges();
            return(RedirectToAction("Success"));
        }
コード例 #17
0
        void InitHocPhi()
        {
            HocPhi    hp = new HocPhi();
            DataTable dt = hp.getAll(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword());


            dtHocPhi = new DataTable();
            dtHocPhi.Columns.Add("SOTIEN", typeof(string));
            dtHocPhi.Columns.Add("MAHP", typeof(string));
            var rowsTarget = dtHocPhi.Rows;

            var rows = dt.Rows;

            for (int i = 0; i < rows.Count; i++)
            {
                rowsTarget.Add(rows[i].Field <string>(2), rows[i].Field <string>(0));
            }

            PopulateHocPhi();
        }
コード例 #18
0
 /// <summary>
 /// Hàm lưu học phí
 /// </summary>
 /// <param name="parameter"></param>
 private void OnSaveHocPhi(UIElementCollection parameter)
 {
     try
     {
         foreach (var child in parameter)
         {
             if (child is ListBox)
             {
                 foreach (var obj in (child as ListBox).Items.SourceCollection)
                 {
                     HocPhiDaoImpl impl   = new HocPhiDaoImpl();
                     HocPhi        hocphi = new HocPhi();
                     hocphi = obj as HocPhi;
                     impl.EditHocPhi(hocphi);
                 }
             }
         }
         MessageBox.Show("Save sussess!");
     }
     catch
     {
         MessageBox.Show("Fail!");
     }
 }
コード例 #19
0
        private void cbxMaLop_TextChanged(object sender, EventArgs e)
        {
            HocPhi hp = new HocPhi();

            txtSoTien.Text = hp.joinsotien(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword(), cbxMaLop.Text);
        }