public static EProp AccessSelectByCodeForConvertor(int Code, OleDbTransaction _transaction, OleDbConnection _connection) { OleDbConnection connection = _connection; OleDbCommand command = new OleDbCommand("E_Prop_Select", connection); command.CommandType = CommandType.StoredProcedure; command.Transaction = _transaction; //connection.Open(); command.Parameters.Add(new OleDbParameter("iCode", Code)); OleDbDataReader reader = command.ExecuteReader(); EProp _EProp = new EProp(); if (reader.Read()) { _EProp.Code = Convert.ToInt32(reader["Code"].ToString()); _EProp.Name = Convert.ToString(reader["Name"].ToString()); _EProp.ProductCode = Convert.ToInt32(reader["ProductCode"].ToString()); _EProp.XCode = new Guid(reader["XCode"].ToString()); } else { _EProp.Code = -1; } reader.Close(); //connection.Close(); return(_EProp); }
public static bool GetFromBProductLocal() { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; DataTable bp = Atend.Base.Base.BProduct.SelectByTypeX(Convert.ToInt32(Atend.Control.Enum.ProductType.Prop)); ed.WriteMessage("bp.Count={0}\n", bp.Rows.Count); foreach (DataRow dr in bp.Rows) { EProp Prop = Atend.Base.Equipment.EProp.SelectByProductCode(Convert.ToInt32(dr["ID"].ToString())); if (Prop.Code != -1) { ed.WriteMessage("Prop.Name={0}\n", Prop.Name); Prop.Name = dr["Name"].ToString(); ed.WriteMessage("ProductCode={0}\n", dr["ID"].ToString()); Prop.ProductCode = Convert.ToInt32(dr["ID"].ToString()); if (!Prop.UpdateX()) { return(false); } } else { ed.WriteMessage("InsertProp\n"); Prop.ProductCode = Convert.ToInt32(dr["ID"].ToString()); Prop.Name = dr["Name"].ToString(); if (!Prop.InsertX()) { return(false); } } } return(true); }
public static EProp SelectByCodeForLocal(int Code, SqlTransaction LocalTransaction, SqlConnection LocalConnection) { SqlConnection connection = LocalConnection; SqlCommand command = new SqlCommand("E_Prop_Select", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("iCode", Code)); EProp Prop = new EProp(); try { command.Transaction = LocalTransaction; SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { Prop.Code = Convert.ToInt16(reader["Code"].ToString()); Prop.Name = reader["Name"].ToString(); Prop.ProductCode = Convert.ToInt32(reader["ProductCode"].ToString()); Prop.XCode = new Guid(reader["XCode"].ToString()); Prop.IsDefault = Convert.ToBoolean(reader["IsDefault"].ToString()); } else { Prop.Code = -1; } reader.Close(); } catch (Exception ex) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage("Error EProp.In SelectByXCode.TransAction:{0}\n", ex.Message); } return(Prop); }
public static EProp SelectByProductCode(int ProductCode) { SqlConnection connection = new SqlConnection(Atend.Control.ConnectionString.LocalcnString); SqlCommand command = new SqlCommand("E_Prop_SelectByProductCode", connection); command.CommandType = CommandType.StoredProcedure; connection.Open(); command.Parameters.Add(new SqlParameter("iProductCode", ProductCode)); SqlDataReader reader = command.ExecuteReader(); EProp Prop = new EProp(); if (reader.Read()) { Prop.Code = Convert.ToInt16(reader["Code"].ToString()); Prop.Name = reader["Name"].ToString(); Prop.ProductCode = Convert.ToInt32(reader["ProductCode"].ToString()); Prop.XCode = new Guid(reader["XCode"].ToString()); Prop.IsDefault = Convert.ToBoolean(reader["IsDefault"].ToString()); } else { Prop.Code = -1; } reader.Close(); connection.Close(); Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; //ed.WriteMessage(string.Format(" Values: {0} , {1} , {2} \n", bus.ProductCode, bus.Size, bus, bus.Type)); return(Prop); }