/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { decimal qty = 0; string error = string.Empty; if (UniGridUpdated.RowsCount == 0) { error = "The list of country to update is empty"; } if (string.IsNullOrEmpty(error)) { if (rdoAmount.Checked) { try { qty = decimal.Parse(txtAmount.Text); } catch { error = "Error: invalid amount"; } } else { try { qty = decimal.Parse(txtPercent.Text); } catch { error = "Error: invalid percentage"; } } } if (!string.IsNullOrEmpty(error)) { ShowError(error); } else { if (UpdatePrice(rdoUnitPrice.Checked, rdoAmount.Checked, qty)) { txtAmount.Text = string.Empty; txtPercent.Text = string.Empty; iCountry.Clear(); DisplayUpdatedCountries(); UniGridUpdated.ReBind(); ShowChangesSaved(); } else { ShowWarning("Some error occured", "Update not performed", string.Empty); } } }
private void DisplayUpdatedCountries() { GeneralConnection cn = ConnectionHelper.GetConnection(); string query = getSQL(); DataSet ds = cn.ExecuteQuery(query, null, QueryTypeEnum.SQLQuery, false); ds.Tables[0].PrimaryKey = new DataColumn[1] { ds.Tables[0].Columns["CountryID"] }; DataTable table = ds.Tables[0]; table.Rows.Clear(); GetAndUpdateCustomTableQueryItem(); //DataSet dsAvailable = (DataSet)UniGridAvailable.DataSource; //dsAvailable.Tables[0].PrimaryKey = new DataColumn[1] { dsAvailable.Tables[0].Columns["CountryID"] }; foreach (int i in iCountry) { DataRow drow = table.NewRow(); DataRow findrow = dsAvailable.Tables[0].Rows.Find(i.ToString()); if (findrow != null) { drow["CountryId"] = findrow["CountryID"]; drow["CountryDisplayName"] = findrow["CountryDisplayName"]; drow["UnitPrice"] = findrow["UnitPrice"]; drow["ShippingBase"] = findrow["ShippingBase"]; table.Rows.Add(drow); } DataRow d = dsAvailable.Tables[0].Rows.Find(i.ToString()); if (d != null) { dsAvailable.Tables[0].Rows.Remove(d); } } UniGridUpdated.DataSource = ds; UniGridUpdated.DataBind(); UniGridAvailable.ReBind(); SetConfirmText(null, null); }