private void BindDataToEdit(DataGridViewCellEventArgs e) { if (e.RowIndex == grvCost.RowCount - 1 || e.RowIndex == -1) { return; } DataGridViewRow row = grvCost.Rows[e.RowIndex]; int costId = int.Parse(row.Cells[COST_ID].Value.ToString()); JSManagementDataSet.CostDataTable costData = costTableAdapter.GetById(costId); if (costData.Rows.Count == 1) { lbCostHeader.Text = "Sửa Chi Phí".ToUpper(); lbCostId.Text = costId.ToString(); txtCostName.Text = costData[0].CostName; txtAmount.Text = costData[0].Amount.ToString("#,###"); cbCostType.SelectedValue = costData[0].CostTypeId; TextBox txtCustId = customerSelectUserControl.Controls.Find("txtCustId", true)[0] as TextBox; txtCustId.Text = costData[0].CustomerId.ToString(); if (cbCostType.Text == Constant.CostType.BANK_TRANSFER) { cboxBankAccount.SelectedValue = costData[0].BankAccountId; } dateTimePickerCostDate.Value = costData[0].CostDate; } }
private void BindDataToEdit(int costId) { JSManagementDataSet.CostDataTable costData = costTableAdapter.GetById(costId); if (costData.Rows.Count == 1) { lbCostHeader.Text = "Sửa Chi Phí".ToUpper(); lbCostId.Text = costId.ToString(); txtCostName.Text = costData[0].CostName; txtAmount.Text = costData[0].Amount.ToString("#,###"); cbCostType.SelectedValue = costData[0].CostTypeId; TextBox txtCustId = customerSelectUserControl.Controls.Find("txtCustId", true)[0] as TextBox; txtCustId.Text = costData[0].CustomerId.ToString(); if (cbCostType.Text == Constant.CostType.BANK_TRANSFER) { cboxBankAccount.SelectedValue = costData[0].BankAccountId; } dateTimePickerCostDate.Value = costData[0].CostDate; } }