コード例 #1
0
        public ActionResult ThemKhoanChi(DateTime ngaythem, string loaikc, int sotien, string ghichu, string loaitaikhoan)
        {
            KhoanChi kc = new KhoanChi();

            kc.matv   = (string)Session[Ses_Admin.Admin];
            kc.ngay   = ngaythem;
            kc.loaikc = loaikc;

            kc.sotien     = sotien;
            kc.ghichu     = ghichu;
            kc.tutaikhoan = loaitaikhoan;

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

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

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("IndexKhoanChi"));
                }
                else
                {
                    ModelState.AddModelError("", "Không thêm được!");
                }
            }
            return(Redirect("~/Error/Error"));
        }
コード例 #2
0
        public ActionResult SuaKhoanChi(int makc, DateTime ngaythem, string loaikc, int sotien, string ghichu, string loaitaikhoan)
        {
            KhoanChi kc = new KhoanChi();

            kc.makc   = makc;
            kc.ngay   = ngaythem;
            kc.loaikc = loaikc;

            kc.sotien     = sotien;
            kc.ghichu     = ghichu;
            kc.tutaikhoan = loaitaikhoan;

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

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

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("IndexKhoanChi"));
                }
                else
                {
                    return(Redirect("~/Error/Error"));
                }
            }
        }
コード例 #3
0
        public List <KhoanChi> GetKhoanChi(string matv, DateTime ngaybatdau, DateTime ngayketthuc)
        {
            const string proc = "SP_XemKhoanChiCaNhan";

            List <SqlParameter> parameters = new List <SqlParameter>()
            {
                new SqlParameter("matv", matv),
                new SqlParameter("ngaybatdau", ngaybatdau),
                new SqlParameter("ngayketthuc", ngayketthuc)
            };

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

            List <KhoanChi> result = new List <KhoanChi>();

            KhoanChi kc = null;

            while (reader.Read())
            {
                kc          = new KhoanChi();
                kc.makc     = Convert.ToString(reader["MaKC"]);
                kc.ngay     = Convert.ToDateTime(reader["Ngay"]);
                kc.sotien   = Convert.ToDouble(reader["SoTien"]);
                kc.khoanchi = Convert.ToString(reader["KhoanChi"]);
                kc.ghichu   = Convert.ToString(reader["GhiChu"]);

                result.Add(kc);
            }

            return(result);
        }
コード例 #4
0
        public List <KhoanChi> GetKhoanChiTrongNgay(string matv, string ngay)
        {
            const string        proc       = "SP_CacKhoanChiTrongNgay";
            List <SqlParameter> parameters = new List <SqlParameter>()
            {
                new SqlParameter("matv", matv),
                new SqlParameter("ngay", ngay)
            };
            IDataReader     reader = DataProvider.ExecuteReader(proc, parameters);
            List <KhoanChi> result = new List <KhoanChi>();
            KhoanChi        kc     = null;

            while (reader.Read())
            {
                kc            = new KhoanChi();
                kc.makc       = Convert.ToInt32(reader["MaKC"]);
                kc.ngay       = Convert.ToDateTime(reader["Ngay"]);
                kc.loaikc     = Convert.ToString(reader["TenLKC"]);
                kc.sotien     = Convert.ToDouble(reader["SoTien"]);
                kc.ghichu     = Convert.ToString(reader["GhiChu"]);
                kc.tutaikhoan = Convert.ToString(reader["TenTaiKhoan"]);
                result.Add(kc);
            }
            return(result);
        }
コード例 #5
0
        public ActionResult SuaKhoanChi(int makc)
        {
            LoadDataForComboLKC();
            LoadDataForComboLoaiTaiKhoan();
            KhoanChi res = new KhoanChi();

            res = LayKhoanChiTheoMa(makc);

            return(View(res));
        }
コード例 #6
0
        //Tìm kiếm theo mã
        public IHttpActionResult GetKC(string MaKC)
        {
            KhoanChi res = dao.SearchKhoanChi(MaKC);

            if (res == null)
            {
                return(NotFound());
            }

            return(Ok(res));
        }
コード例 #7
0
        public IHttpActionResult PutKC([FromBody] KhoanChi kc)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            if (!dao.PutKhoanChi(kc))//sửa
            {
                return(BadRequest("Not a valid model"));
            }

            return(Ok());
        }
コード例 #8
0
 public bool XoaKC(int ma, int manguoidung)
 {
     try
     {
         KhoanChi kt = context.KhoanChis.Single(sv => sv.makhoanchi == ma && sv.mand == manguoidung);
         context.KhoanChis.DeleteOnSubmit(kt);
         context.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #9
0
        private void frmThemhoacsuaKC_Load(object sender, EventArgs e)
        {
            LoadDataForComboLKC();
            LoadDataForComboLoaiTaiKhoan();

            if (KhoanChi_Session.themhoacsua == 2)
            {
                btnThem.Text = "Sửa";
                int      makc = KhoanChi_Session.makc;
                KhoanChi kc   = LayKhoanChiTheoMa(makc);
                cboLoaiKC.SelectedValue   = kc.loaikc;
                dtpNgay.Value             = kc.ngay;
                txtSoTien.Text            = kc.sotien.ToString();
                txtGhiChu.Text            = kc.ghichu;
                cboTaiKhoan.SelectedValue = kc.tutaikhoan;
            }
            else
            {
                btnThem.Text = "Thêm";
            }
        }
コード例 #10
0
        public KhoanChi SearchKhoanChi(string MaKC)
        {
            const string        proc = "SP_TimKiemKhoanChi";
            List <SqlParameter> para = new List <SqlParameter>()
            {
                new SqlParameter("makc", MaKC)
            };
            IDataReader reader = DataProvider.ExecuteReader(proc, para);
            KhoanChi    kchi   = new KhoanChi();

            while (reader.Read())
            {
                kchi            = new KhoanChi();
                kchi.makc       = Convert.ToInt32(reader["MaKC"]);
                kchi.ngay       = Convert.ToDateTime(reader["Ngay"]);
                kchi.loaikc     = Convert.ToString(reader["LoaiKC"]);
                kchi.sotien     = Convert.ToDouble(reader["SoTien"]);
                kchi.ghichu     = Convert.ToString(reader["GhiChu"]);
                kchi.tutaikhoan = Convert.ToString(reader["TuTaiKhoan"]);
            }
            return(kchi);
        }
コード例 #11
0
        public KhoanChi LayKhoanChiTheoMa(int makc)
        {
            KhoanChi kc = new KhoanChi();

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

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

                    kc = readTask.Result;
                    return(kc);
                }
            }
            return(kc);
        }
コード例 #12
0
        public bool PostKhoanChi(KhoanChi kc)
        {
            const string        proc = "SP_ThemKhoanChi";
            List <SqlParameter> para = new List <SqlParameter>()
            {
                new SqlParameter("matv", kc.matv),
                new SqlParameter("ngay", kc.ngay),
                new SqlParameter("loaikc", kc.loaikc),
                new SqlParameter("sotien", kc.sotien),
                new SqlParameter("ghichu", kc.ghichu),
                new SqlParameter("tutaikhoan", kc.tutaikhoan)
            };
            int res = DataProvider.ExecuteNonQuery(proc, para);

            if (res > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #13
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (KhoanChi_Session.themhoacsua == 2)
            {
                KhoanChi kc = new KhoanChi();
                kc.loaikc     = (string)cboLoaiKC.SelectedValue;
                kc.ngay       = dtpNgay.Value;
                kc.sotien     = Convert.ToInt32(txtSoTien.Text.Trim());
                kc.ghichu     = txtGhiChu.Text.Trim();
                kc.tutaikhoan = (string)cboTaiKhoan.SelectedValue;
                kc.makc       = KhoanChi_Session.makc;
                kc.matv       = matv;

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

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

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

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

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