//static object LockObject = new object(); public static bool AddInfo(int typeID, InfoClass info, ProductClass product, Dictionary <int, string> keyvalues) { string sql = "insert into T_Info (Title, TypeID) values ('" + info.Title + "', " + info.TypeId.ToString() + ")"; SqlCommand cmd = SqlDAL.Connection.CreateCommand(); cmd.Transaction = SqlDAL.Connection.BeginTransaction(IsolationLevel.RepeatableRead); bool insert = SqlDAL.ExecuteNonQuery(sql, cmd); if (insert) { int infoID = SqlDAL.GetMaxID("ID", "T_Info"); List <KeyClass> keys = GetKeys(infoID, false); foreach (KeyClass key in keys) { string sql1 = "insert into T_KeyValue (KeyId, Value) values (@KeyId, @Value)"; cmd.Parameters.AddWithValue("@KeyId", key.Id); cmd.Parameters.AddWithValue("@Value", keyvalues[key.Id]); SqlDAL.ExecuteNonQuery(sql1, cmd); } string sql2 = "insert into T_Product (Picture) values (@Picture)"; cmd.Parameters.AddWithValue("@Picture", GetBytesFromImageList(product.Picture)); bool insert1 = SqlDAL.ExecuteNonQuery(sql2, cmd); if (insert1) { SqlDAL.CommitTransaction(cmd); return(true); } } return(false); }