public void Rename(string key, string name, BeforeEditEventHandler bfEdit, BeforeEditInDatabaseEventHandler bfDbEdit, AfterEditEventHandler afEdit, AfterEditEventHandler afEditAndCommit) { //string sql = "UPDATE {0} SET [{1}] = '{2}') WHERE [{3}]='{4}'"; //string query = string.Format(sql,view.DataTable.TableName, view.DisplayColumn, name, view.PrimaryKeyFileds[0].DatabaseNames,key); Dictionary <string, object> values = new Dictionary <string, object>(); //values.Add(view.PrimaryKeyFileds[0].Name, key); values.Add(view.DisplayColumn, name); DataAccess.SqlAccess da = new DataAccess.SqlAccess(); da.Edit(view, values, key, bfEdit, bfDbEdit, afEdit, afEditAndCommit); }
public static void AssignToParent(this View view, string newParent, string[] pks, BeforeEditEventHandler beforeEditCallback, BeforeEditInDatabaseEventHandler beforeEditInDatabaseEventHandler, AfterEditEventHandler afterEditBeforeCommitCallback, AfterEditEventHandler afterEditAfterCommitCallback) { if (!view.AllowEdit) { throw new AccessViolationException(); } ICopyPaste assignCommand = GetCopyPaste(view); try { foreach (string pk in pks) { Dictionary <string, object> values = new Dictionary <string, object>(); values.Add(view.TreeRelatedFieldName, newParent); assignCommand.Edit(view, values, pk, beforeEditCallback, beforeEditInDatabaseEventHandler, afterEditBeforeCommitCallback, afterEditAfterCommitCallback); } } catch (Exception exeption) { assignCommand.PasteCommit(true); throw new DuradosException(exeption.Message); } finally { try { assignCommand.CloseConnections(); } catch { } } assignCommand.PasteCommit(false); }
public static void Edit(this View view, Dictionary <string, object> values, string pk, BeforeEditEventHandler beforeEditCallback, BeforeEditInDatabaseEventHandler beforeEditInDatabaseEventHandler, AfterEditEventHandler afterEditBeforeCommitCallback, AfterEditEventHandler afterEditAfterCommitCallback) { if (!view.AllowEdit) { throw new AccessViolationException(); } GetDataTableAccess(view).Edit(view, values, pk, beforeEditCallback, beforeEditInDatabaseEventHandler, afterEditBeforeCommitCallback, afterEditAfterCommitCallback); }
public void EditField(View view, string fieldName, object fieldValue, string pk, BeforeEditEventHandler beforeEditCallback, BeforeEditInDatabaseEventHandler beforeEditInDatabaseCallback, AfterEditEventHandler afterEditBeforeCommitCallback, AfterEditEventHandler afterEditAfterCommitCallback) { Dictionary <string, object> values = new Dictionary <string, object>(); values.Add(fieldName, LocalizeValue(view, fieldName, fieldValue)); view.Edit(values, pk, beforeEditCallback, beforeEditInDatabaseCallback, afterEditBeforeCommitCallback, afterEditAfterCommitCallback); }
public void CopyPasteView(View view, Json.CopyPaste jsonView, BeforeEditEventHandler beforeEditCallback, BeforeEditInDatabaseEventHandler beforeEditInDatabaseCallback, AfterEditEventHandler afterEditBeforeCommitCallback, AfterEditEventHandler afterEditAfterCommitCallback) { string pk = ""; int RowsNumber = jsonView.GetRowsNumber(); ICopyPaste cpCommand = view.GetCopyPaste(); try { int multi = 1; int newRownumber = 0; int valuesCount = jsonView.Source.FieldsValues.Count; if (RowsNumber > valuesCount && RowsNumber % valuesCount == 0) { multi = (int)(RowsNumber / valuesCount); RowsNumber = valuesCount; } else if (RowsNumber != valuesCount) { throw new DuradosException("Rows number do not match Source data selected"); } for (int m = 1; m <= multi; m++) { for (int r = 0; r < RowsNumber; r++) { int names = jsonView.Source.FieldsNames.Count; if (names != jsonView.Source.FieldsValues[r].Count) { throw new DuradosException("Source values do not match Source Fields Names"); } Dictionary <string, object> values = new Dictionary <string, object>(); object value; for (int i = 0; i < names; i++) { value = LocalizeValue(view, jsonView.Source.FieldsNames[i], jsonView.Source.FieldsValues[r][i]); values.Add(jsonView.Source.FieldsNames[i], value); } pk = jsonView.Destination.RowsPKs[newRownumber + r]; cpCommand.Edit(view, values, pk, beforeEditCallback, beforeEditInDatabaseCallback, afterEditBeforeCommitCallback, afterEditAfterCommitCallback); } newRownumber += RowsNumber; } cpCommand.PasteCommit(false); } catch (Exception exeption) { cpCommand.PasteCommit(true); throw new DuradosException(exeption.Message); //"Error while processing data, Paste operation cancelled!"); } finally { try { cpCommand.CloseConnections(); } catch { } } }
public void EditRow(View view, Json.View jsonView, string pk, bool ignoreNull, BeforeEditEventHandler beforeEditCallback, BeforeEditInDatabaseEventHandler beforeEditInDatabaseCallback, AfterEditEventHandler afterEditBeforeCommitCallback, AfterEditEventHandler afterEditAfterCommitCallback) { Dictionary <string, object> values = new Dictionary <string, object>(); foreach (Json.Field jsonField in jsonView.Fields.Values) { if (!(ignoreNull && !jsonField.Refresh && (jsonField.Value == null || jsonField.Value.ToString() == string.Empty || jsonField.Value.Equals(false)))) { object value; if (view.Fields.ContainsKey(jsonField.Name)) { if (view.Fields[jsonField.Name].FieldType == FieldType.Column && ((ColumnField)view.Fields[jsonField.Name]).DataColumn.DataType.Equals(typeof(byte[]))) { value = ((ColumnField)view.Fields[jsonField.Name]).ConvertFromString(jsonField.Value.ToString()); } else { value = LocalizeValue(view, jsonField.Name, jsonField.Value); } values.Add(jsonField.Name, value); } else { values.Add(jsonField.Name, jsonField.Value); } } } view.Edit(values, pk, beforeEditCallback, beforeEditInDatabaseCallback, afterEditBeforeCommitCallback, afterEditAfterCommitCallback); }