Пример #1
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            float soTienChi;
            bool  isfloatChi = float.TryParse(txtSoTien.Text.Trim().ToString(), out soTienChi);

            if (txtKhoanChi.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập tên khoản chi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtKhoanChi.Focus();
                return;
            }
            else if (!isfloatChi || float.Parse(txtSoTien.Text) < 0)
            {
                MessageBox.Show("Bạn phải nhập số tiền", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtSoTien.Focus();
                return;
            }
            else
            {
                DTO_KhoanChi kc = new DTO_KhoanChi(txtMaKC.Text, txtKhoanChi.Text, dtpkNgayChi.Value, float.Parse(txtSoTien.Text), txtMoTa.Text);
                if (busKhoanChi.UpdateKhoanChi(kc))
                {
                    MessageBox.Show("Sửa thành công");
                    ResetValues();
                    LoadGridView_KhoanChi();
                }
                else
                {
                    MessageBox.Show("Sửa không thành công");
                }
            }
        }
Пример #2
0
        public bool UpdateKhoanChi(DTO_KhoanChi kc)
        {
            try
            {
                _conn.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = _conn;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "UpdateDataIntoKhoanChi";
                cmd.Parameters.AddWithValue("maKC", kc.MaKC);
                cmd.Parameters.AddWithValue("tenkhoanchi", kc.TenKC);
                cmd.Parameters.AddWithValue("ngaychi", kc.NgayChi);
                cmd.Parameters.AddWithValue("sotien", kc.SoTien);
                cmd.Parameters.AddWithValue("mota", kc.MoTa);

                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            finally
            {
                _conn.Close();
            }
            return(false);
        }
Пример #3
0
 public bool UpdateKhoanChi(DTO_KhoanChi kc)
 {
     return(dalKhoanChi.UpdateKhoanChi(kc));
 }
Пример #4
0
 public bool InsertKhoanChi(DTO_KhoanChi kc)
 {
     return(dalKhoanChi.InsertKhoanChi(kc));
 }