private async void btnUpdate_Click_1(object sender, EventArgs e) { try { if (txtName.Text.Trim() == string.Empty || txtAmount.Text.Trim() == string.Empty) { MessageBox.Show("All fields required...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtName.Focus(); return; } if (!System.Text.RegularExpressions.Regex.IsMatch(txtName.Text, "^[a-zA-Z]")) { MessageBox.Show("Invaild Name...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtName.Focus(); txtName.Text.Remove(txtName.Text.Length - 1); return; } _borrow.Amount = (decimal)Convert.ToDouble(txtAmount.Text); _borrow.CustomerName = Convert.ToString(txtName.Text); _borrow.IsReturned = cbxIsDeposited.Checked; await _borrowRepository.Update(_borrow); OnLoadData(); this.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static void ManageBorrow(Borrow borrow, EntityState entityState) { IBorrowRepository borrowRepository = new BorrowRepository(); borrow.EntityState = entityState; if (borrow.Quantity == 0 && entityState == EntityState.Modified) { borrow.IsReturn = true; borrow.ReturnTime = DateTime.Now; } borrowRepository.Update(borrow); }