コード例 #1
0
        public ReturnObjValueBackEnd InsertSaveMoney(SoTietKiem objInsert)
        {
            retObjValueBackEnd = new ReturnObjValueBackEnd();
            try
            {
                var    ctx   = new BankingContext();
                string maxId = "";
                maxId = (from c in ctx.SoTietKiem select c.MaSTK).Max();

                if (!string.IsNullOrEmpty(maxId))
                {
                    int    maxCurrent  = Convert.ToInt16(maxId.Substring(3, maxId.Length - 2));
                    int    maxNext     = maxCurrent + 1;
                    string mastkaddnew = maxNext.ToString().PadLeft(4, '0');
                    objInsert.MaSTK = "STK" + mastkaddnew;
                }
                else
                {
                    objInsert.MaSTK = "STK0001";
                }

                ctx.SoTietKiem.Add(objInsert);
                ctx.SaveChanges();
                retObjValueBackEnd.Success = true;
                return(retObjValueBackEnd);
            }
            catch (Exception ex)
            {
                retObjValueBackEnd.Success = false;
                retObjValueBackEnd.Message = ex.ToString();
                return(retObjValueBackEnd);

                throw ex;
            }
        }
コード例 #2
0
        public HttpResponseMessage Add([FromBody] SoTietKiem stk)
        {
            var stkBus = new BankMgmt.MW.BusinessLayer.SoTietKiemBUS();

            stkBus.AddSoTietKiem(stk);
            return(Request.CreateResponse(HttpStatusCode.Created, stk));
        }
コード例 #3
0
ファイル: useKhachHang.cs プロジェクト: PhanVi/QLSoTietKiem
        /// <summary>
        /// them khach hang
        /// </summary>
        /// <param name="kh"></param>
        /// <param name="stk"></param>
        public void ThemKH(KhachHang kh, SoTietKiem stk)
        {
            string sql = "insert into KhachHang values (N'" + kh.MaKH + "', N'" + kh.HoKH + "', N'" + kh.TenKH + "', '" +
                         kh.NgaySinh.ToString("yyyy-MM-dd HH:mm:ss") + "', N'" + kh.GioiTinh + "', '" + kh.SDT + "',  N'" + kh.QuocTich + "')";

            string sql2 = "insert into SoTietKiem values(N'" + stk.MaSTK + "', N'" + kh.MaKH + "', '" +
                          stk.SoTien + "', '" + stk.LoaiTien + "', '" + stk.LaiSuat + "', N'" + stk.KyHan + "')";

            try
            {
                cnn = new SqlConnection(str);
                cnn.Open();
                SqlCommand cmd = new SqlCommand(sql, cnn);
                cmd.ExecuteNonQuery();
                cmd = new SqlCommand(sql2, cnn);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                cnn.Close();
                cnn.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
        public List <SoTietKiem> SearchSaveMoneyByCondition(SoTietKiem sc)
        {
            List <SoTietKiem> lst = new List <SoTietKiem>();

            try
            {
                var ctx   = new BankingContext();
                var query = from ct in ctx.SoTietKiem
                            select ct;

                if (sc != null)
                {
                    if (sc.MaSTK != null)
                    {
                        query = query.Where(p => p.MaSTK.Equals(sc.MaSTK));
                    }

                    if (sc.MaKH != null)
                    {
                        query = query.Where(p => p.MaKH.Equals(sc.MaKH));
                    }

                    if (sc.NgayTao != null)
                    {
                        query = query.Where(p => p.NgayTao.Equals(sc.NgayTao));
                    }
                    if (sc.NgayHuy != null)
                    {
                        query = query.Where(p => p.NgayHuy.Equals(sc.NgayHuy));
                    }
                    if (sc.MaNV != null)
                    {
                        query = query.Where(p => p.MaNV.Equals(sc.MaNV));
                    }
                    if (sc.MaCN != null)
                    {
                        query = query.Where(p => p.MaCN.Equals(sc.MaCN));
                    }

                    if (sc.LoaiTK != null)
                    {
                        query = query.Where(p => p.LoaiTK.Equals(sc.LoaiTK));
                    }
                    if (sc.SoTien != null)
                    {
                        query = query.Where(p => p.SoTien.Equals(sc.SoTien));
                    }
                }

                lst = query.ToList();
                return(lst);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
        public HttpResponseMessage RemoveSoTietKiem(int stkId)
        {
            var        stkBus = new BankMgmt.MW.BusinessLayer.SoTietKiemBUS();
            SoTietKiem stk    = stkBus.GetSoTietKiem(stkId);

            stk.TinhTrang = 0;
            stkBus.UpdateSoTietKiem(stk);
            return(Request.CreateResponse(HttpStatusCode.Created, stkId));
        }
コード例 #6
0
 public void InsertSaveMoney(SoTietKiem objInsert)
 {
     try
     {
         var ctx = new BankingContext();
         ctx.SoTietKiem.Add(objInsert);
         ctx.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #7
0
 public void UpdateSaveMoney(SoTietKiem objUpdate)
 {
     try
     {
         var ctx = new BankingContext();
         ctx.Entry(objUpdate).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #8
0
        public ReturnObjValueBackEnd UpdateSaveMoney(SoTietKiem objUpdate)
        {
            retObjValueBackEnd = new ReturnObjValueBackEnd();
            try
            {
                var ctx = new BankingContext();
                ctx.Entry(objUpdate).State = System.Data.Entity.EntityState.Modified;
                ctx.SaveChanges();
                retObjValueBackEnd.Success = true;
                return(retObjValueBackEnd);
            }
            catch (Exception ex)
            {
                retObjValueBackEnd.Success = false;
                retObjValueBackEnd.Message = ex.ToString();
                return(retObjValueBackEnd);

                throw ex;
            }
        }
コード例 #9
0
        private void btnDangKy_Click(object sender, EventArgs e)
        {
            if (useKH.MaKHLaNULL(txtMaKH.Text))
            {
                MessageBox.Show("Mã Khách hàng không được trống!", "Cảnh báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (useKH.HoKHLaNULL(txtHo.Text) == true)
            {
                MessageBox.Show("Họ Khách hàng không được trống!", "Cảnh báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (useKH.TenKHLaNULL(txtTen.Text) == true)
            {
                MessageBox.Show("Tên Khách hàng không được trống!", "Cảnh báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (useKH.SDTLaNULL(txtSDT.Text) == true)
            {
                MessageBox.Show("SDT Khách hàng không được trống!", "Cảnh báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (useKH.QuocTichLaNULL(txtQuocTich.Text) == true)
            {
                MessageBox.Show("Họ Khách hàng không được trống!", "Cảnh báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (useKH.GioiTinhLaNULL(txtGioiTinh.Text) == true)
            {
                MessageBox.Show("Giới tính Khách hàng không được trống!", "Cảnh báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            else if (useSTK.MaSTKLaNULL(txtMaSTK.Text) == true)
            {
                MessageBox.Show("Mã số tiết kiệm không được trống!", "Cảnh báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (useSTK.SoTienGuiaNULL(txtSoTien.Text) == true)
            {
                MessageBox.Show("Mời nhập số tiền gửi ban đầu!", "Cảnh báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (useSTK.TienLaiaNULL(txtLaiSuat.Text) == true)
            {
                MessageBox.Show("Mời nhập lãi suất ban đầu!", "Cảnh báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }


            else
            {
                try
                {
                    KhachHang  kh  = new KhachHang(txtMaKH.Text, txtHo.Text, txtTen.Text, dtpNgaySinh.Text, txtGioiTinh.Text, txtSDT.Text, txtQuocTich.Text);
                    SoTietKiem stk = new SoTietKiem(txtMaSTK.Text, txtMaSTK.Text, txtSoTien.Text, txtLoaiTien.Text, txtLaiSuat.Text, cbKyHan.Text);



                    useKH.ThemKH(kh, stk);

                    gridThemMoiSTK.DataSource = useSTK.getDataSoTietKiem();

                    MessageBox.Show("Đăng ký thành công!");
                    init();
                    //sinh ma kh
                    SinhMaKH MaKhachHang = new SinhMaKH();
                    txtMaKH.Text = MaKhachHang.SinhMaKHtu().ToString();

                    //sinh ma sotietkiem
                    SinhMaSTK MaSoTietKiem = new SinhMaSTK();
                    txtMaSTK.Text = MaSoTietKiem.SinhMaSTKtu().ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    //throw;
                }
            }
        }
コード例 #10
0
        public ReturnObjValueBackEnd SearchSaveMoneyByCondition(SoTietKiem sc)
        {
            retObjValueBackEnd = new ReturnObjValueBackEnd();
            List <SoTietKiem> lst = new List <SoTietKiem>();

            try
            {
                var ctx   = new BankingContext();
                var query = from ct in ctx.SoTietKiem
                            select ct;

                if (sc != null)
                {
                    if (sc.MaSTK != null)
                    {
                        query = query.Where(p => p.MaSTK.Equals(sc.MaSTK));
                    }

                    if (sc.MaKH != null)
                    {
                        query = query.Where(p => p.MaKH.Equals(sc.MaKH));
                    }

                    if (sc.NgayTao != null)
                    {
                        query = query.Where(p => p.NgayTao.Equals(sc.NgayTao));
                    }
                    if (sc.NgayHuy != null)
                    {
                        query = query.Where(p => p.NgayHuy.Equals(sc.NgayHuy));
                    }
                    if (sc.MaNV != null)
                    {
                        query = query.Where(p => p.MaNV.Equals(sc.MaNV));
                    }
                    if (sc.MaCN != null)
                    {
                        query = query.Where(p => p.MaCN.Equals(sc.MaCN));
                    }

                    if (sc.LoaiTK != null)
                    {
                        query = query.Where(p => p.LoaiTK.Equals(sc.LoaiTK));
                    }
                    if (sc.SoTien != null)
                    {
                        query = query.Where(p => p.SoTien.Equals(sc.SoTien));
                    }
                }

                lst = query.ToList();
                retObjValueBackEnd.Success = true;
                retObjValueBackEnd.Data    = lst.ToArray();
                return(retObjValueBackEnd);
            }
            catch (Exception ex)
            {
                retObjValueBackEnd.Success = false;
                retObjValueBackEnd.Message = ex.ToString();
                return(retObjValueBackEnd);

                throw ex;
            }
        }
コード例 #11
0
        public void LaiXuatNULLSoTietKiemTests()
        {
            SoTietKiem stk = new SoTietKiem("STK05", "KH02", "8000000", "VND", "", "1 tháng");

            Assert.IsNull(LaiXuat);
        }
コード例 #12
0
        public void MaKHNULLSoTietKiemTests()
        {
            SoTietKiem stk = new SoTietKiem("STK05", "", "8000000", "VND", "2.3", "1 tháng");

            Assert.IsNull(MaKH);
        }
コード例 #13
0
        public void MaSTKNULLSoTietKiemTests()
        {
            SoTietKiem stk = new SoTietKiem("", "KH02", "8000000", "VND", "2.3", "1 tháng");

            Assert.IsNull(MaSTK);
        }
コード例 #14
0
        public void SoTienGuiaNULLSoTietKiemTests()
        {
            SoTietKiem stk = new SoTietKiem("STK05", "KH02", "", "VND", "2.3", "1 tháng");

            Assert.IsNull(SoTien);
        }