Esempio n. 1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            Check check = new Check();

            if (txtGiaVay.Text == "")
            {
                lblError.Text = "Bạn chưa nhập giá vay";
            }
            else if (txtTiLeVay.Text == "")
            {
                lblError.Text = "Bạn chưa nhập tỉ lệ vay";
            }
            else if (!check.LaMotSoNguyenDuong(txtTiLeVay.Text) || long.Parse(txtTiLeVay.Text) <= 0 || long.Parse(txtTiLeVay.Text) >= 100)
            {
                lblError.Text = "Tỉ lệ vay không hợp lệ";
            }
            else if (!check.LaMotSoNguyenDuong(txtGiaVay.Text))
            {
                lblError.Text = "Giá vay không hợp lệ";
            }

            else
            {
                QLRoCKBUS qLRoCKBUS = new QLRoCKBUS();

                string jsonData = qLRoCKBUS.timKiem(txtMaRo.Text);

                List <QLRoCKDTO> list     = JsonConvert.DeserializeObject <List <QLRoCKDTO> >(jsonData);
                List <String>    listName = new List <string>();

                if (list != null)
                {
                    foreach (QLRoCKDTO temp in list)
                    {
                        listName.Add(temp.MaCK);
                    }
                }


                if (list == null || !listName.Contains(cmbMaCK.Text))
                {
                    QLRoCKDTO qLRoCKDTO = new QLRoCKDTO();
                    qLRoCKDTO.MaRo    = txtMaRo.Text;
                    qLRoCKDTO.MaCK    = cmbMaCK.Text;
                    qLRoCKDTO.GiaVay  = long.Parse(txtGiaVay.Text);
                    qLRoCKDTO.TiLeVay = long.Parse(txtTiLeVay.Text);

                    string jsonDataAdd = JsonConvert.SerializeObject(qLRoCKDTO);
                    if (qLRoCKBUS.ThemCK(jsonDataAdd))
                    {
                        MessageBox.Show("Thêm mã chứng khoán mới thành công", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Close();
                    }
                }
                else
                {
                    lblError.Text = "Mã CK đã tồn tại trong rổ";
                }
            }
        }
Esempio n. 2
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            try
            {
                //Kiểm tra lỗi nhập
                QLRoCKBUS roCKBUS = new QLRoCKBUS();
                switch (roCKBUS.KTThongTinSuaRoCK(txtGiaVay.Text, txtTiLeVay.Text))
                {
                case 1:
                {
                    lblError.Text = "Giá vay không được để trống";
                    break;
                }

                case 2:
                {
                    lblError.Text = "Tỉ lệ vay không được để trống";
                    break;
                }

                case 3:
                {
                    lblError.Text = "Giá vay không hợp lệ";
                    break;
                }

                case 4:
                {
                    lblError.Text = "Tỉ lệ vay không hợp lệ";
                    break;
                }

                case 0:
                {
                    lblError.Text = "";

                    if (roCKBUS.suaTTMaCK(txtMaRo.Text, txtmaCK.Text, txtGiaVay.Text, txtTiLeVay.Text))
                    {
                        MessageBox.Show("Sửa mã chứng khoán thành công", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Đã có lỗi xảy ra, sửa mã chứng khoán thất bại", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
        private void txtMaRo_Leave(object sender, EventArgs e)
        {
            try
            {
                txtGiaVay.Text  = "";
                txtTiLeVay.Text = "";
                QLRoCKBUS qLRoCKBUS = new QLRoCKBUS();
                //lấy thông tin từ số TKLK
                string jsonData  = qLRoCKBUS.timKiem(txtMaRo.Text);
                string jsonTenRo = qLRoCKBUS.layTenRo(txtMaRo.Text);

                RoCK             tenRoCK = JsonConvert.DeserializeObject <RoCK>(jsonTenRo);
                List <QLRoCKDTO> list    = JsonConvert.DeserializeObject <List <QLRoCKDTO> >(jsonData);

                lblError.ForeColor = Color.Red;
                if (txtMaRo.Text == "")
                {
                    lblError.Text = "Bạn chưa nhập mã rổ";
                }
                else
                if (tenRoCK == null)
                {
                    lblError.Text = "Mã rổ không có trong hệ thống";
                }
                else
                {
                    txtTenRo.Text = tenRoCK.TenRo;
                    lblError.Text = "";

                    string      jsonDataCK = qLRoCKBUS.layDSMaCK();
                    List <MaCK> listMaCK   = JsonConvert.DeserializeObject <List <MaCK> >(jsonDataCK);
                    // Hiển thị lên cmb
                    cmbMaCK.Refresh();
                    cmbMaCK.DataSource    = listMaCK;
                    cmbMaCK.DisplayMember = "MaCk";
                    cmbMaCK.SelectedIndex = 0;

                    if (list != null)
                    {
                        // Xóa dữ liệu hiển thị cũ
                        gridView.Rows.Clear();
                        foreach (QLRoCKDTO temp in list)
                        {
                            gridView.Rows.Add(temp.MaCK, temp.GiaVay, temp.TiLeVay);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
        private void btnThem_Click_1(object sender, EventArgs e)
        {
            try
            {
                QLRoCKBUS qLRo = new QLRoCKBUS();
                switch (qLRo.KTThongTinThemRoCK(txtTenRo.Text))
                {
                case 1:
                {
                    lblError.Text = "Bạn chưa nhập Tên Rổ";
                    break;
                }

                case 2:
                {
                    lblError.Text = "Tên rổ không hợp lệ";
                    break;
                }

                case 0:
                {
                    lblError.Text = "";
                    RoCK roCK = new RoCK();

                    roCK.MaRo  = txtMaRo.Text;
                    roCK.TenRo = txtTenRo.Text;

                    string jsonDataAdd = JsonConvert.SerializeObject(roCK);
                    if (qLRo.ThemRoCK(jsonDataAdd))
                    {
                        QLRoCKDTO qLRoCKDTO = new QLRoCKDTO();
                        qLRoCKDTO.MaRo = txtMaRo.Text;

                        string jsonData = JsonConvert.SerializeObject(qLRoCKDTO);


                        MessageBox.Show("Thêm rổ mới thành công", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Đã có lỗi xảy ra, thêm rổ mới thất bại", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
0
        private void txtMaRo_Leave(object sender, EventArgs e)
        {
            try
            {
                if (txtMaRo.Text != "")
                {
                    lblError.Text = "";
                    QLRoCKBUS qLRoCKBUS = new QLRoCKBUS();
                    //lấy thông tin từ số TKLK
                    string           jsonData = qLRoCKBUS.timKiem(txtMaRo.Text);
                    List <QLRoCKDTO> list     = JsonConvert.DeserializeObject <List <QLRoCKDTO> >(jsonData);

                    lblError.ForeColor = Color.Red;
                    if (list != null)
                    {
                        gridView.Rows.Clear();
                        foreach (QLRoCKDTO temp in list)
                        {
                            txtTenRo.Text = temp.TenRo;

                            lblError.Text = "";

                            // Xóa dữ liệu hiển thị cũ
                            gridView.Rows.Add(temp.MaCK, temp.TenCK, temp.GiaVay, temp.TiLeVay);
                        }
                    }
                    else
                    {
                        lblError.Text = "Mã rổ không có trong hệ thống";
                        gridView.Rows.Clear();
                    }
                }
                else
                {
                    gridView.Rows.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (gridView.RowCount > 0 && gridView.SelectedRows.Count > 0)
     {
         DialogResult dr = MessageBox.Show("Bạn có chắc chắn muốn xóa mã chứng khoán " + gridView.SelectedRows[0].Cells[0].Value.ToString(), "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (dr == DialogResult.Yes)
         {
             QLRoCKBUS qLRoCKBUS = new QLRoCKBUS();
             if (qLRoCKBUS.XoaMaCK(txtMaRo.Text, gridView.SelectedRows[0].Cells[0].Value.ToString()))
             {
                 MessageBox.Show("Xóa mã CK thành công", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show("Đã có lỗi xảy ra, xóa mã CK thất bại", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         MessageBox.Show("Thao tác lỗi. Bạn chưa chọn mã chứng khoán nào", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 7
0
        private void ThemRoCK_Load(object sender, EventArgs e)
        {
            QLRoCKBUS qLRo = new QLRoCKBUS();

            txtMaRo.Text = qLRo.taoMaRo();
        }