public override void OnOkeyClick() { Command comm = new Database.Command(DatabaseManager.Instance.Connection); var item = new OrdersManager.Model.Project(); item.ProjectName = base.ProjectName; item.ProjectStatus = base.ProjectStatus; item.ProjectCost = base.ProjectCost; item.TeamLeadId = base.TeamLeadId; item.StartDate = base.StartDate; item.FinalDate = base.FinalDate; comm.InsertProject(item); Views.ProjectInsertView.Instance.Close(); //base.OnOkeyClick(); }
private void SyncForeignKeys(ForeignKeySyncConnection spec, int value) { var sql = new StringBuilder("INSERT INTO [TABLENAME] ([PRIMARYKEYNAME]) VALUES ([VALUE])"); sql.Replace("[TABLENAME]", spec.TableName); sql.Replace("[PRIMARYKEYNAME]", spec.PrimaryKeyName); sql.Replace("[VALUE]", value.ToString()); var result = new Database.Command(spec.ConnectionIndex, sql.ToString(), _ioSystem, true).ExecuteScalar(); }
private Return<bool> DeleteUsingIOSystem(params int[] ids) { if (ids.Length != 0) { if (DeleteForeignKeys(ids)) { System.Text.StringBuilder sql = new System.Text.StringBuilder("DELETE FROM [TABLE] WHERE ([ID] IN ([IDS]))"); string keys = string.Join(",", ids); sql.Replace("[TABLE]", _source); sql.Replace("[ID]", _id); sql.Replace("[IDS]", keys); using (Database.Command cmd = new Database.Command(_connectionIndex, sql.ToString(), _ioSystem, false)) { return cmd.ExecuteNonQuery(); } } else { return new Return<bool>(Return<bool>.ResultEnum.Success, "Unable to delete, item in use.", "", false); } } else { return new Return<bool>(Return<bool>.ResultEnum.Success, "No Ids specified", "", false); } }
private bool DeleteForeignKeys(int value) { bool rollBack = false; foreach (ForeignKeySyncConnection spec in _foreignKeySyncConnections) { var sql = new StringBuilder("DELETE FROM [TABLENAME] WHERE ([PRIMARYKEYNAME] = [VALUE])"); sql.Replace("[TABLENAME]", spec.TableName); sql.Replace("[PRIMARYKEYNAME]", spec.PrimaryKeyName); sql.Replace("[VALUE]", value.ToString()); spec.Deleted = false; // Reset to default value var result = new Database.Command(spec.ConnectionIndex, sql.ToString(), _ioSystem, true).ExecuteScalar(); if (result.Success) { spec.Deleted = true; } else { rollBack = true; break; } } if (rollBack) { foreach (ForeignKeySyncConnection spec in _foreignKeySyncConnections) { if (spec.Deleted) SyncForeignKeys(spec, value); } return false; } return true; }
private Return<bool> RunUpdateSQLWithIOSystem() { string sql = UpdateSQL(); try { if (sql.Length != 0) { using (Database.Command cmd = new Database.Command(_view.ConnectionIndex, sql.ToString(), _ioSystem, false)) { return TrapErrors(cmd.ExecuteNonQuery()); } } else { return new Return<bool>(Return<bool>.ResultEnum.Success, "Nothing to update.", "", true); } } catch (Exception ex) { return new Return<bool>(Return<bool>.ResultEnum.Fatal, ex.Message, "", false); } }
public virtual void OnOkeyClick() { Database.Command comm = new Database.Command(Database.DatabaseManager.Instance.Connection); comm.UpdateProject(this.Project); }