Exemplo n.º 1
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            KhoanThu kt = new KhoanThu();

            kt.makt     = txtMakt.Text.Trim();
            kt.matv     = cboMaTV.Text;
            kt.ngay     = dtpNgay.Value;
            kt.loaikt   = cboLoaiKT.Text;
            kt.khoanthu = txtKhoanThu.Text.Trim();
            float sotien;

            float.TryParse(txtSoTien.Text.Trim(), out sotien);
            kt.sotien = sotien;
            kt.ghichu = txtGhiChu.Text.Trim();

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

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

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    MessageBox.Show("Sửa dữ liệu thành công");
                }
                else
                {
                    MessageBox.Show(":(");
                }
            }
        }
Exemplo n.º 2
0
        public List <KhoanThu> GetKhoanThuTrongNgay(string matv, string ngay)
        {
            const string        proc = "SP_CacKhoanThuTrongNgay";
            List <SqlParameter> para = new List <SqlParameter>()
            {
                new SqlParameter("matv", matv),
                new SqlParameter("ngay", ngay)
            };
            IDataReader     reader = DataProvider.ExecuteReader(proc, para);
            List <KhoanThu> result = new List <KhoanThu>();
            KhoanThu        kthu;

            while (reader.Read())
            {
                kthu             = new KhoanThu();
                kthu.makt        = Convert.ToInt32(reader["MaKT"]);
                kthu.loaikt      = Convert.ToString(reader["TenLKT"]);
                kthu.ngay        = Convert.ToDateTime(reader["Ngay"]);
                kthu.sotien      = Convert.ToInt32(reader["SoTien"]);
                kthu.ghichu      = Convert.ToString(reader["GhiChu"]);
                kthu.dentaikhoan = Convert.ToString(reader["TenTaiKhoan"]);
                result.Add(kthu);
            }
            return(result);
        }
Exemplo n.º 3
0
        public bool PutKhoanThu(KhoanThu kt)
        {
            const string proc = "SP_SuaKhoanThu";

            List <SqlParameter> para = new List <SqlParameter>()
            {
                new SqlParameter("makt", kt.makt),
                new SqlParameter("matv", kt.matv),
                new SqlParameter("ngay", kt.ngay),
                new SqlParameter("loaikt", kt.loaikt),
                new SqlParameter("khoanthu", kt.khoanthu),
                new SqlParameter("sotien", kt.sotien),
                new SqlParameter("ghichu", kt.ghichu)
            };

            int res = DataProvider.ExecuteNonQuery(proc, para);

            if (res != 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        public KhoanThu SearchKhoanThu(string MaKT)
        {
            const string        proc = "SP_TimKiemKhoanThu";
            List <SqlParameter> para = new List <SqlParameter>()
            {
                new SqlParameter("makt", MaKT)
            };
            IDataReader reader = DataProvider.ExecuteReader(proc, para);
            KhoanThu    res    = new KhoanThu();
            KhoanThu    kthu;

            while (reader.Read())
            {
                kthu             = new KhoanThu();
                kthu.matv        = Convert.ToString(reader["MaThanhVien"]);
                kthu.makt        = Convert.ToInt32(reader["MaKT"]);
                kthu.loaikt      = Convert.ToString(reader["LoaiKT"]);
                kthu.ngay        = Convert.ToDateTime(reader["Ngay"]);
                kthu.sotien      = Convert.ToInt32(reader["SoTien"]);
                kthu.ghichu      = Convert.ToString(reader["GhiChu"]);
                kthu.dentaikhoan = Convert.ToString(reader["DenTaiKhoan"]);
                res = kthu;
            }
            return(res);
        }
Exemplo n.º 5
0
        public List <KhoanThu> GetKhoanThu(string matv)
        {
            const string proc = "SP_XemKhoanThuCaNhanDemo";

            List <SqlParameter> para = new List <SqlParameter>()
            {
                new SqlParameter("matv", matv)
            };

            IDataReader reader = DataProvider.ExecuteReader(proc, para);

            List <KhoanThu> result = new List <KhoanThu>();
            KhoanThu        kthu;

            while (reader.Read())
            {
                kthu          = new KhoanThu();
                kthu.matv     = Convert.ToString(reader["MaThanhVien"]);
                kthu.makt     = Convert.ToString(reader["MaKT"]);
                kthu.loaikt   = Convert.ToString(reader["TenLKT"]);
                kthu.ngay     = Convert.ToDateTime(reader["Ngay"]);
                kthu.sotien   = Convert.ToDouble(reader["SoTien"]);
                kthu.khoanthu = Convert.ToString(reader["KhoanThu"]);
                kthu.ghichu   = Convert.ToString(reader["GhiChu"]);

                result.Add(kthu);
            }

            return(result);
        }
        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            string makt = txtTimKiem.Text.Trim();

            KhoanThu kt = null;

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

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

                    kt = readTask.Result;
                    MessageBox.Show("Tìm Thấy!");
                    List <KhoanThu> res = new List <KhoanThu>();
                    res.Add(kt);
                    dgvKhoanThu.DataSource = res;
                }
                else
                {
                    MessageBox.Show("K Thấy!");
                }
            }
        }
        public ActionResult SuaKhoanThu(int makt, DateTime ngaythem, string loaikt, int sotien, string ghichu, string loaitaikhoan)
        {
            KhoanThu kt = new KhoanThu();

            kt.makt        = makt;
            kt.ngay        = ngaythem;
            kt.loaikt      = loaikt;
            kt.sotien      = sotien;
            kt.ghichu      = ghichu;
            kt.dentaikhoan = loaitaikhoan;

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

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

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("IndexKhoanThu", new { @thoigian = DateTime.Now.ToString("MM-yyyy") }));
                }
                else
                {
                    return(Redirect("~/Error/Error"));
                }
            }
        }
        public ActionResult ThemKhoanThu(DateTime ngaythem, string loaikt, int sotien, string ghichu, string loaitaikhoan)
        {
            KhoanThu kt = new KhoanThu();

            kt.matv        = (string)Session[Ses_Admin.Admin];
            kt.ngay        = ngaythem;
            kt.loaikt      = loaikt;
            kt.sotien      = sotien;
            kt.ghichu      = ghichu;
            kt.dentaikhoan = loaitaikhoan;

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

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

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("IndexKhoanThu", new { @thoigian = DateTime.Now.ToString("MM-yyyy") }));
                }
                else
                {
                    ModelState.AddModelError("", "Không thêm được!");
                }
            }
            return(Redirect("~/Error/Error"));
        }
Exemplo n.º 9
0
        //Tìm kiếm theo mã
        public IHttpActionResult Get_TimKiem(string MaKT)
        {
            KhoanThu res = dao.SearchKhoanThu(MaKT);

            if (res == null)
            {
                return(NotFound());
            }
            return(Ok(res));
        }
        public ActionResult SuaKhoanThu(int makt)
        {
            LoadDataForComboLKT();
            LoadDataForComboLoaiTaiKhoan();
            KhoanThu res = new KhoanThu();

            res = LayKhoanThuTheoMa(makt);

            return(View(res));
        }
Exemplo n.º 11
0
 public bool XoaKT(int ma, int manguoidung)
 {
     try
     {
         KhoanThu kt = context.KhoanThus.Single(sv => sv.makhoanthu == ma && sv.mand == manguoidung);
         context.KhoanThus.DeleteOnSubmit(kt);
         context.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 12
0
        public IHttpActionResult PutKT([FromBody] KhoanThu kt)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

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

            return(Ok());
        }
Exemplo n.º 13
0
        public HttpStatusCodeResult PutKT([FromBody] KhoanThu kt)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(404));
            }

            if (!dao.PutKhoanThu(kt))
            {
                return(new HttpStatusCodeResult(404));
            }

            return(new HttpStatusCodeResult(200));
        }
        private void frmThemMoiKhoanThu_Load(object sender, EventArgs e)
        {
            LoadDataForComboLKT();
            LoadDataForComboLoaiTaiKhoan();

            if (KhoanThu_Session.themhoacsua == 2)
            {
                btnThem.Text = "Sửa";
                int      makt = KhoanThu_Session.makt;
                KhoanThu kt   = LayKhoanThuTheoMa(makt);
                cboLoaiKT.SelectedValue   = kt.loaikt;
                dtpNgay.Value             = kt.ngay;
                txtSoTien.Text            = kt.sotien.ToString();
                txtGhiChu.Text            = kt.ghichu;
                cboTaiKhoan.SelectedValue = kt.dentaikhoan;
            }
            else
            {
                btnThem.Text = "Thêm";
            }
        }
        public KhoanThu LayKhoanThuTheoMa(int makt)
        {
            KhoanThu kt = new KhoanThu();

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

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

                    kt = readTask.Result;
                    return(kt);
                }
            }
            return(kt);
        }
Exemplo n.º 16
0
        public bool PostKhoanThu(KhoanThu kt)
        {
            const string        proc = "SP_ThemKhoanThu";
            List <SqlParameter> para = new List <SqlParameter>()
            {
                new SqlParameter("MaThanhVien", kt.matv),
                new SqlParameter("Ngay", kt.ngay),
                new SqlParameter("LoaiKT", kt.loaikt),
                new SqlParameter("SoTien", kt.sotien),
                new SqlParameter("GhiChu", kt.ghichu),
                new SqlParameter("DenTaiKhoan", kt.dentaikhoan)
            };
            int res = DataProvider.ExecuteNonQuery(proc, para);

            if (res > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (KhoanThu_Session.themhoacsua == 2)
            {
                KhoanThu kt = new KhoanThu();
                kt.loaikt      = (string)cboLoaiKT.SelectedValue;
                kt.ngay        = dtpNgay.Value;
                kt.sotien      = Convert.ToInt32(txtSoTien.Text.Trim());
                kt.ghichu      = txtGhiChu.Text.Trim();
                kt.dentaikhoan = (string)cboTaiKhoan.SelectedValue;
                kt.makt        = KhoanThu_Session.makt;
                kt.matv        = thanhvien;

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

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

                    var result = postTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        MessageBox.Show("Đã Sửa!");
                    }
                    else
                    {
                        MessageBox.Show("404 Error");
                    }
                }
            }
            else
            {
                KhoanThu kt = new KhoanThu();
                kt.loaikt      = (string)cboLoaiKT.SelectedValue;
                kt.ngay        = dtpNgay.Value;
                kt.sotien      = Convert.ToInt32(txtSoTien.Text.Trim());
                kt.ghichu      = txtGhiChu.Text.Trim();
                kt.dentaikhoan = (string)cboTaiKhoan.SelectedValue;
                kt.matv        = thanhvien;
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(baseAddress);

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

                    var result = postTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        MessageBox.Show("Đã Thêm!");
                    }
                    else
                    {
                        MessageBox.Show("404 Error");
                    }
                }
            }
        }