public static Dictionary <string, int> GetAbstractionDictionary() { Logging.Log(Severity.Verbose, global::System.Reflection.MethodBase.GetCurrentMethod().Name); //TODO : Create GetAbstractionList Stored Procedure throw new NotImplementedException(); Dictionary <String, int> abstractions = new Dictionary <string, int>(); using (PLDbConnection dbConn = DataAccess.ConnectionOpen()) { using (PLDbCommand dbCmd = new PLDbCommand("GetAbstractionList", dbConn)) { using (PLDbDataReader dbDr = dbCmd.ExecuteReader()) { while (dbDr.Read()) { // TODO : Someday determine if there is a meaningful speed difference. //Globals.Attributes.Add(dbDr.GetString(1), dbDr.GetInt32(0)); abstractions.Add(dbDr["Abstraction_Name"].ToString(), (int)dbDr["Abstraction_ID"]); } } } } return(abstractions); }
public static int UpdateAttribute(PLDbConnection dbConn, int shapeID, string shapeTypeAttributeName, string attributeValue) { PLDbCommand dbCmd; int shapeTypeAttributeID; // TODO: Get the attributeID for the passed in attributeName if ((shapeTypeAttributeID = DataAccess.GetShapeTypeAttributeID(shapeTypeAttributeName)) > 0) { dbCmd = new PLDbCommand("SetAttributeValue", dbConn); dbCmd.CommandType = CommandType.StoredProcedure; dbCmd.AddParameter("@Table", SqlDbType.Int, 0).Value = Globals.TABLE_SHAPE; dbCmd.AddParameter("@ID", SqlDbType.Int, 0).Value = shapeID; dbCmd.AddParameter("@STA_ID", SqlDbType.Int, 0).Value = shapeTypeAttributeID; dbCmd.AddParameter("@Function", SqlDbType.Int, 0).Value = Globals.LOGFUNCTION_SET_ATTRIBUTEVALUE; dbCmd.AddParameter("@Contact", SqlDbType.VarChar, 100).Value = global::System.Security.Principal.WindowsIdentity.GetCurrent().Name; dbCmd.AddParameter("@Value", SqlDbType.VarChar, 100).Value = attributeValue; dbCmd.ExecuteNonQuery(); return(Globals.SUCCESS); } else { return(Globals.FAILURE); } }
public static Dictionary <string, int> GetShapeTypeDictionary() { Dictionary <String, int> shapes = new Dictionary <string, int>(); Logging.Log(Severity.Verbose, global::System.Reflection.MethodBase.GetCurrentMethod().Name); using (PLDbConnection dbConn = DataAccess.ConnectionOpen()) { using (PLDbCommand dbCmd = new PLDbCommand("GetShapeTypeList", dbConn)) { dbCmd.CommandType = CommandType.StoredProcedure; // TODO : Why do I have to pass DBNull.Value? dbCmd.AddParameter("@ABSTRACTION", SqlDbType.Int, 0).Value = DBNull.Value; using (PLDbDataReader dbDr = dbCmd.ExecuteReader()) { while (dbDr.Read()) { // TODO : Someday determine if there is a meaningful speed difference. //Globals.Attributes.Add(dbDr.GetString(1), dbDr.GetInt32(0)); shapes.Add(dbDr["ShapeType_Name"].ToString(), (int)dbDr["ShapeType_ID"]); } } } } return(shapes); }
private void btnExport_Click(object sender, global::System.EventArgs e) { PLDbConnection dbConn; PLDbCommand dbCmd; string sqlCmd; DataTable dbTable; DataTableReader dbTableReader; Excel.Worksheet ws = (Excel.Worksheet)Application.ActiveSheet; Excel.Range rng; Application.ScreenUpdating = false; Logging.Log(Severity.Verbose, "btnExport_Click"); dbConn = DataAccess.ConnectionOpen(); rng = (Excel.Range)ws.Cells[3, 1]; sqlCmd = "EXEC GetItem " + Globals.TABLE_SHAPE + "," + rng.Value2; dbCmd = new PLDbCommand(sqlCmd, dbConn); dbTable = dbCmd.ExecuteDataTable(); Logging.Log(Severity.Verbose, "After ExecuteDataTable"); dbTableReader = dbTable.CreateDataReader(); Logging.Log(Severity.Verbose, "After CreateDataReader"); for (int j = 0; j < dbTable.Rows.Count; j++, row++) { dbTableReader.Read(); for (int i = 0; i < dbTableReader.FieldCount; i++) // fields are zero based { rng = (Excel.Range)ws.Cells[row, i + 1]; rng.Value2 = dbTableReader.GetValue(i).ToString(); //(Excel.Range)ws.Cells[i, j].Value2 = dbTableReader.GetValue(i).ToString(); //MessageBox.Show(dbTableReader.GetValue(i).ToString()); } } //MessageBox.Show(dbTableReader.GetValue(1).ToString() + " " + dbTableReader.GetValue(2).ToString() + " " + dbTableReader.GetValue(3).ToString()); //MessageBox.Show(dbTable.Rows.ToString()); //dbDataSet = dbCmd.ExecuteDataSet(); Logging.Log(Severity.Verbose, "After for loops"); dbConn.Close(); Logging.Log(Severity.Verbose, "After dbClose"); Application.ScreenUpdating = true; }
public static int CreateShape(PLDbConnection dbConn, string shapeType, string shapeName, string shapeDescription, out int shapeID) { // TODO : Update with using and handle errors. // TODO : Can we pass in a dbCmd and have the common stuff already populated? PLDbCommand dbCmd; // Create the Shape dbCmd = new PLDbCommand("SetShape", dbConn); dbCmd.CommandType = CommandType.StoredProcedure; dbCmd.AddParameter("@Table", SqlDbType.Int, 0).Value = Globals.TABLE_SHAPE; dbCmd.AddParameter("@ShapeType", SqlDbType.Int, 0).Value = Globals.ShapeTypes[shapeType]; dbCmd.AddParameter("@Lifecycle", SqlDbType.Int, 0).Value = Globals.LIFECYCLE_CURRENT; dbCmd.AddParameter("@Function", SqlDbType.Int, 0).Value = Globals.LOGFUNCTION_SET_SHAPE; dbCmd.AddParameter("@Contact", SqlDbType.VarChar, 100).Value = global::System.Security.Principal.WindowsIdentity.GetCurrent().Name; dbCmd.AddParameter("@Value", SqlDbType.VarChar, 100).Value = shapeName; dbCmd.AddParameter("@NewID", SqlDbType.Int, 0).Direction = ParameterDirection.Output; dbCmd.ExecuteNonQuery(); shapeID = (int)dbCmd.GetParameter("@NewID").Value; dbCmd.Dispose(); dbCmd = new PLDbCommand("SetItem_Desc", dbConn); dbCmd.CommandType = CommandType.StoredProcedure; dbCmd.AddParameter("@Table", SqlDbType.Int, 0).Value = Globals.TABLE_SHAPE; dbCmd.AddParameter("@ID", SqlDbType.Int, 0).Value = shapeID; dbCmd.AddParameter("@Value", SqlDbType.VarChar, 1000).Value = shapeDescription; dbCmd.AddParameter("@Function", SqlDbType.Int, 0).Value = Globals.LOGFUNCTION_SET_SHAPE; dbCmd.AddParameter("@Contact", SqlDbType.VarChar, 100).Value = global::System.Security.Principal.WindowsIdentity.GetCurrent().Name; dbCmd.ExecuteNonQuery(); dbCmd.Dispose(); return(Globals.SUCCESS); }