public static void FromTextControls(AutoCompleteTextBox[] textBoxes,string[] textFieldNames,EMDataRow row) { for (int i=0;i<textBoxes.Length;i++) { // Don't apply an empty string over a null field if (row.IsNull(textFieldNames[i]) && textBoxes[i].Text.Length == 0) continue; row[textFieldNames[i]] = textBoxes[i].Text; } }
public static void FromDateControls(AutoCompleteTextBox[] dateBoxes,string[]dateFieldNames,EMDataRow row) { for (int i=0;i<dateBoxes.Length;i++) { if (dateBoxes[i].Text == "") { row[dateFieldNames[i]] = DBNull.Value; } else { row[dateFieldNames[i]] = dateBoxes[i].Text; } } }
public static void UpdateTextControls(AutoCompleteTextBox[] textBoxes,string[] textFieldNames,EMDataRow row, bool isEmptyTable) { for (int i=0;i<textBoxes.Length;i++) { textBoxes[i].Enabled = !isEmptyTable; if (row.IsNull(textFieldNames[i])) { textBoxes[i].Text = ""; } else { textBoxes[i].Text = (string)row[textFieldNames[i]]; } } }
public static void UpdateDateControls(AutoCompleteTextBox[] dateBoxes,Button[] dateButtons, string[] dateFieldNames,EMDataRow row,bool isEmptyTable) { for (int i=0;i<dateBoxes.Length;i++) { dateBoxes[i].Enabled = !isEmptyTable; dateButtons[i].Enabled = !isEmptyTable; if (row.IsNull(dateFieldNames[i])) { dateBoxes[i].Text = ""; } else { DateTime date = (DateTime)row[dateFieldNames[i]]; dateBoxes[i].Text = HelperFunctions.ToDateText(date); } } }
public static void OnDateLeave(object sender,AutoCompleteTextBox[] dateBoxes,string[] dateFields, EMDataRow row) { AutoCompleteTextBox dateBox = null; string dateField=""; for (int i=0;i<dateBoxes.Length;i++) { if (sender == dateBoxes[i]) { dateBox = dateBoxes[i]; dateField = dateFields[i]; break; } } Debug.Assert(dateBox != null); try { if (dateBox.Text == "") row[dateField] = DBNull.Value; else row[dateField] = dateBox.Text; } catch(Exception ex) { MessageBox.Show(ex.Message); } if (row.IsNull(dateField)) { dateBox.Text = ""; } else { dateBox.Text = HelperFunctions.ToDateText( (DateTime)row[dateField]); } }
public static DialogResult OnDateBtn(object sender,Button[] dateButtons,AutoCompleteTextBox[] dateBoxes, string[] dateFieldNames,EMDataRow row,out DateTime dateTime) { // first find the control int i=0; for (i=0;i<dateButtons.Length;i++) { if (sender == dateButtons[i]) { break; } } Debug.Assert(i!= dateButtons.Length); string fieldName = dateFieldNames[i]; AutoCompleteTextBox box = dateBoxes[i]; if (row.IsNull(fieldName)) dateTime = System.DateTime.Today; else dateTime = (DateTime)row[fieldName]; if (DialogResult.OK == DateTimeSelector.RequestTime(ref dateTime)) { box.Text = HelperFunctions.ToDateText(dateTime); return DialogResult.OK; } return DialogResult.Cancel; }
public static void TransferFinish(string columnName, DataRow sourceRow,EMDataRow targetRow) { object finishID; if (sourceRow.IsNull(columnName)) finishID = DBNull.Value; else { string finishType = (string)sourceRow[columnName]; finishID = HelperFunctions.GetFinishKey(columnName,finishType); } string keyName = columnName + "ID"; targetRow[keyName] = finishID; }