Exemplo n.º 1
0
        public ActionResult SuaKhoanVay(int id, DateTime ngayvay, int sotien, string nguoivay, string taikhoanchitieu)
        {
            KhoanVay_ChoVay kt = new KhoanVay_ChoVay();

            kt.id        = id;
            kt.ngayvay   = ngayvay;
            kt.sotien    = sotien;
            kt.thanhvien = (string)Session[Ses_Admin.Admin];
            kt.loai      = "1";
            kt.nguoivay  = nguoivay;

            kt.taikhoanchitieu = taikhoanchitieu;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(baseAddress);

                //HTTP POST
                var postTask = client.PutAsJsonAsync <KhoanVay_ChoVay>("KhoanVay", kt);
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(kt));
                }
            }
        }
        private KhoanVay_ChoVay LaykhoanVayTheoMa()
        {
            int manv = KhoanVay_Session.ma;

            KhoanVay_ChoVay kt = new KhoanVay_ChoVay();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(baseAddress);
                //HTTP GET
                var responseTask = client.GetAsync($"KhoanVay/{manv}");
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <KhoanVay_ChoVay>();
                    readTask.Wait();

                    kt = readTask.Result;
                    return(kt);
                }
                else
                {
                    return(null);
                }
            }
        }
Exemplo n.º 3
0
        public ActionResult ThemKhoanChoVay(DateTime ngayvay, int sotien, string nguoivay, string taikhoanchitieu)
        {
            KhoanVay_ChoVay kt = new KhoanVay_ChoVay();

            kt.ngayvay   = ngayvay;
            kt.sotien    = sotien;
            kt.thanhvien = (string)Session[Ses_Admin.Admin];
            kt.loai      = "2";
            kt.nguoivay  = nguoivay;

            kt.taikhoanchitieu = taikhoanchitieu;


            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(baseAddress);

                //HTTP POST
                var postTask = client.PostAsJsonAsync <KhoanVay_ChoVay>("KhoanChoVay", kt);
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Không thêm được!");
                }
            }
            return(RedirectToAction("ThemKhoanChoVay"));
        }
        public KhoanVay_ChoVay SearchKhoanChoVay(int id)
        {
            const string        proc = "SP_TimKiemKhoanChoVay";
            List <SqlParameter> para = new List <SqlParameter>()
            {
                new SqlParameter("id", id)
            };
            IDataReader     reader = DataProvider.ExecuteReader(proc, para);
            KhoanVay_ChoVay res    = new KhoanVay_ChoVay();
            KhoanVay_ChoVay kthu;

            while (reader.Read())
            {
                kthu = new KhoanVay_ChoVay();

                kthu.id              = Convert.ToInt32(reader["id"]);
                kthu.ngayvay         = Convert.ToDateTime(reader["NgayVay"]);
                kthu.sotien          = Convert.ToInt32(reader["SoTien"]);
                kthu.thanhvien       = Convert.ToString(reader["ThanhVien"]);
                kthu.loai            = Convert.ToString(reader["Loai"]);
                kthu.nguoivay        = Convert.ToString(reader["NguoiVay"]);
                kthu.taikhoanchitieu = Convert.ToString(reader["TaiKhoanChiTieu"]);
                res = kthu;
            }
            return(res);
        }
Exemplo n.º 5
0
        public IHttpActionResult Get_TimKiem(int id)
        {
            KhoanVay_ChoVay res = dao.SearchKhoanChoVay(id);

            if (res == null)
            {
                return(NotFound());
            }
            return(Ok(res));
        }
Exemplo n.º 6
0
        public ActionResult SuaKhoanVay(int id)
        {
            LoadDataForComboLoaiTaiKhoan();
            LoadDataForComboNguoiVay();

            KhoanVay_ChoVay res = new KhoanVay_ChoVay();

            res = LayKhoanVayTheoMa(id);

            return(View(res));
        }
Exemplo n.º 7
0
        public IHttpActionResult PutKCV([FromBody] KhoanVay_ChoVay kt)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            if (!dao.PutKhoanChoVay(kt))
            {
                return(BadRequest("Not a valid model"));
            }

            return(Ok());
        }
 private void frmThemHoacSuaKhoanVay_Load(object sender, EventArgs e)
 {
     LoadDataForComboLoaiTaiKhoan();
     LoadDataForComboNguoivay();
     if (KhoanVay_Session.themhoacsua == 1)//vua click them
     {
         btnThem.Text = "Thêm";
     }
     else//vua click sua
     {
         btnThem.Text = "Sửa";
         KhoanVay_ChoVay nv = LaykhoanVayTheoMa();
         dtpNgay.Value             = nv.ngayvay;
         txtSoTien.Text            = Convert.ToString(nv.sotien);
         cboNguoiVay.SelectedValue = nv.nguoivay;
         cboTaiKhoan.SelectedValue = nv.taikhoanchitieu;
         //txtTen.Text = nv.ten;
         //txtSDT.Text = Convert.ToString(nv.sdt);
     }
 }
Exemplo n.º 9
0
        public KhoanVay_ChoVay LayKhoanVayTheoMa(int id)
        {
            KhoanVay_ChoVay kt = new KhoanVay_ChoVay();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(baseAddress);
                //HTTP GET
                var responseTask = client.GetAsync($"KhoanVay?id={id}");
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <KhoanVay_ChoVay>();
                    readTask.Wait();

                    kt = readTask.Result;
                    return(kt);
                }
            }
            return(kt);
        }
        public bool PostKhoanChoVay(KhoanVay_ChoVay kt)
        {
            const string        proc = "SP_ThemKhoanVay_ChoVay";
            List <SqlParameter> para = new List <SqlParameter>()
            {
                new SqlParameter("ngayvay", kt.ngayvay),
                new SqlParameter("sotien", kt.sotien),
                new SqlParameter("thanhvien", kt.thanhvien),
                new SqlParameter("loai", kt.loai),
                new SqlParameter("nguoivay", kt.nguoivay),
                new SqlParameter("taikhoanchitieu", kt.taikhoanchitieu),
            };
            int res = DataProvider.ExecuteNonQuery(proc, para);

            if (res > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (themhoacsua == 1)
            {
                KhoanVay_ChoVay kt = new KhoanVay_ChoVay();

                kt.ngayvay   = dtpNgay.Value;
                kt.sotien    = Convert.ToInt32(txtSoTien.Text.Trim());
                kt.thanhvien = MySession.tendangnhap;
                kt.loai      = "1";
                kt.nguoivay  = Convert.ToString(cboNguoiVay.SelectedValue);

                kt.taikhoanchitieu = Convert.ToString(cboTaiKhoan.SelectedValue);


                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(baseAddress);

                    //HTTP POST
                    var postTask = client.PostAsJsonAsync <KhoanVay_ChoVay>("KhoanVay", kt);
                    postTask.Wait();

                    var result = postTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        MessageBox.Show("Thêm thành công");
                    }
                    else
                    {
                        MessageBox.Show("Lỗi");
                    }
                }
            }
            else
            {
                KhoanVay_ChoVay kt = new KhoanVay_ChoVay();
                kt.id        = KhoanVay_Session.ma;
                kt.ngayvay   = dtpNgay.Value;
                kt.sotien    = Convert.ToInt32(txtSoTien.Text.Trim());
                kt.thanhvien = MySession.tendangnhap;
                kt.loai      = "1";
                kt.nguoivay  = Convert.ToString(cboNguoiVay.SelectedValue);

                kt.taikhoanchitieu = Convert.ToString(cboTaiKhoan.SelectedValue);

                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(baseAddress);

                    //HTTP POST
                    var postTask = client.PutAsJsonAsync <KhoanVay_ChoVay>("KhoanVay", kt);
                    postTask.Wait();

                    var result = postTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        MessageBox.Show("Sửa thành công");
                    }
                    else
                    {
                        MessageBox.Show("Lỗi");
                    }
                }
            }
        }