private void RefreshCooperatorList() { DataSet ds = new DataSet(); string findText = ""; string searchPKeys = ""; // First get the cooperator_ids for the orginal search criteria (_originalPKeys)... ds = _sharedUtils.GetWebServiceData("get_cooperator", _originalPKeys, 0, 0); searchPKeys = ":cooperatorid="; if (ds.Tables.Contains("get_cooperator")) { foreach (DataRow dr in ds.Tables["get_cooperator"].Rows) { searchPKeys += dr["cooperator_id"].ToString() + ","; } } // Now get the cooperator_ids from the local LU table that match the lastname and first name... if (!string.IsNullOrEmpty(ux_textboxLastName.Text)) { findText += ux_textboxLastName.Text + "%"; } if (!string.IsNullOrEmpty(ux_textboxFirstName.Text)) { findText += ux_textboxFirstName.Text + "%"; } if (!string.IsNullOrEmpty(findText)) { DataTable dt = new DataTable(); dt = _sharedUtils.LookupTablesGetMatchingRows("cooperator_lookup", findText, 1000); foreach (DataRow dr in dt.Rows) { searchPKeys += dr["value_member"].ToString() + ","; } } // Remove the last trailing comma... searchPKeys = searchPKeys.TrimEnd(','); // Finally go get the full collection of cooperator_ids... ds = _sharedUtils.GetWebServiceData("get_cooperator", searchPKeys, 0, 0); if (ds.Tables.Contains("get_cooperator")) { _cooperator = ds.Tables["get_cooperator"].Copy(); } else if (_cooperator == null) { _cooperator = new DataTable(); } // And then update the binding source's data... _cooperatorBindingSource.DataSource = _cooperator; }
private void PopulateDataviewComboboxes(string _selectedObjectTypePropertyName) { DataTable dt; DataSet ds = _sharedUtils.GetWebServiceData("get_dataview_list", "", 0, 0); if (ds.Tables.Contains("get_dataview_list")) { dt = ds.Tables["get_dataview_list"].Copy(); dt.DefaultView.Sort = "title asc"; dt.DefaultView.RowFilter = "category_code='Client' AND primary_key='" + _selectedObjectTypePropertyName + "'"; ux_comboboxDataviewName.ValueMember = "dataview_name"; ux_comboboxDataviewName.DisplayMember = "title"; ux_comboboxDataviewName.DataSource = dt; //ux_comboboxDataviewName.SelectedItem = -1; } }
public void Load() { DataSet remoteDBUserSettings = new DataSet(); // Get the user settings from the remote DB for the current user's CNO... //remoteDBUserSettings = _GRINGlobalWebServices.GetData("GET_RESOURCES", ":name=; :seclangid=" + _lang.ToString(), 0, 0); remoteDBUserSettings = _sharedUtils.GetWebServiceData("GET_RESOURCES", ":name=; :seclangid=" + _lang.ToString(), 0, 0); _appSettings.Clear(); _appSettings = remoteDBUserSettings.Tables["GET_RESOURCES"].Copy(); // Set the primary key for the table from the extended properties... System.Collections.Generic.List <DataColumn> pKeys = new System.Collections.Generic.List <DataColumn>(); foreach (DataColumn dc in _appSettings.Columns) { // Add the column to the primary key list if it is a primary key for the resultset... if (dc.ExtendedProperties.Contains("is_primary_key") && dc.ExtendedProperties["is_primary_key"].ToString() == "Y") { pKeys.Add(dc); } // Set the autoincrement property indicated (typically for the primary key)... if (dc.ExtendedProperties.Contains("is_autoincrement") && dc.ExtendedProperties["is_autoincrement"].ToString() == "Y") { dc.AutoIncrement = true; dc.AutoIncrementSeed = -1; dc.AutoIncrementStep = -1; } } _appSettings.PrimaryKey = pKeys.ToArray(); // Clean up... remoteDBUserSettings.Dispose(); }
private void ux_buttonLoad_Click(object sender, EventArgs e) { _imageDGV.ReadOnly = true; ux_progressbarLoading.Show(); ux_progressbarLoading.Minimum = 0; ux_progressbarLoading.Maximum = _imageDGV.Rows.Count; ux_progressbarLoading.Step = 1; foreach (DataGridViewRow dgvr in _imageDGV.Rows) { string remotePath = ""; // Get the byte array for the image... byte[] imageBytes = System.IO.File.ReadAllBytes(dgvr.Cells["image_file_physical_path"].Value.ToString()); // Attempt to upload the image to the remote server... if (imageBytes != null && !string.IsNullOrEmpty(dgvr.Cells["virtual_path"].Value.ToString())) { remotePath = _sharedUtils.SaveImage(dgvr.Cells["virtual_path"].Value.ToString(), imageBytes, true, true); } // If the upload was successful the remotePath will contain the destination path (so now we can insert the record)... if (!string.IsNullOrEmpty(remotePath)) { // See if any records already exist for this inventory_id and if so update it // otherwise insert a new record... DataSet ds = _sharedUtils.GetWebServiceData("get_accession_inv_attach", ":inventoryid=" + ((DataRowView)dgvr.DataBoundItem).Row["inventory_id"].ToString() + "; :accessionid=; :orderrequestid=; :cooperatorid=;", 0, 0); if (ds.Tables.Contains("get_accession_inv_attach")) { DataRow[] inventoryImageRows = ds.Tables["get_accession_inv_attach"].Select("virtual_path='" + dgvr.Cells["virtual_path"].Value.ToString() + "'"); // This row does not exist - so create a new record... if (inventoryImageRows != null && inventoryImageRows.Length == 0) { DataRow newInventoryImageRow = ds.Tables["get_accession_inv_attach"].NewRow(); newInventoryImageRow["accession_inv_attach_id"] = -1; newInventoryImageRow["inventory_id"] = ((DataRowView)dgvr.DataBoundItem).Row["inventory_id"]; newInventoryImageRow["virtual_path"] = dgvr.Cells["virtual_path"].Value; newInventoryImageRow["thumbnail_virtual_path"] = dgvr.Cells["thumbnail_virtual_path"].Value; //newInventoryImageRow["sort_order"] = dgvr.Cells["sort_order"].Value; //newInventoryImageRow["title"] = dgvr.Cells["title"].Value; //newInventoryImageRow["description"] = dgvr.Cells["description"].Value; //newInventoryImageRow["content_type"] = dgvr.Cells["content_type"].Value; newInventoryImageRow["category_code"] = dgvr.Cells["category_code"].Value; newInventoryImageRow["is_web_visible"] = dgvr.Cells["is_web_visible"].Value; newInventoryImageRow["note"] = dgvr.Cells["note"].Value; ds.Tables["get_accession_inv_attach"].Rows.Add(newInventoryImageRow); } // The row exists already (probably because it was previously uploaded) - so update the first existing record... else if (inventoryImageRows != null && inventoryImageRows.Length > 0) { inventoryImageRows[0]["virtual_path"] = dgvr.Cells["virtual_path"].Value; inventoryImageRows[0]["thumbnail_virtual_path"] = dgvr.Cells["thumbnail_virtual_path"].Value; //newInventoryImageRow["sort_order"] = dgvr.Cells["sort_order"].Value; //newInventoryImageRow["title"] = dgvr.Cells["title"].Value; //newInventoryImageRow["description"] = dgvr.Cells["description"].Value; //newInventoryImageRow["content_type"] = dgvr.Cells["content_type"].Value; inventoryImageRows[0]["category_code"] = dgvr.Cells["category_code"].Value; inventoryImageRows[0]["is_web_visible"] = dgvr.Cells["is_web_visible"].Value; inventoryImageRows[0]["note"] = dgvr.Cells["note"].Value; } // Get the changes that need to be committed to the remote database... DataSet modifiedData = new DataSet(); modifiedData.Tables.Add(ds.Tables["get_accession_inv_attach"].GetChanges()); if (modifiedData.Tables.Contains("get_accession_inv_attach")) { _sharedUtils.SaveWebServiceData(modifiedData); } } } ux_progressbarLoading.PerformStep(); } // Close the form... this.Close(); }